HHH-15924 - Remove the org.hibernate.metamodel.relational package
This commit is contained in:
parent
cbfba13143
commit
748ebe8456
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Column {
|
||||
String getColumnExpression();
|
||||
|
||||
Table getTable();
|
||||
|
||||
JdbcMapping getJdbcMapping();
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
|
||||
/**
|
||||
* A read-only expression (e.g. `x + 1`) to which a ModelPart is mapped
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Formula implements Column {
|
||||
private final Table table;
|
||||
private final String expression;
|
||||
private final JdbcMapping jdbcMapping;
|
||||
|
||||
public Formula(Table table, String expression, JdbcMapping jdbcMapping) {
|
||||
this.table = table;
|
||||
this.expression = expression;
|
||||
this.jdbcMapping = jdbcMapping;
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnExpression() {
|
||||
return getExpression();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
return jdbcMapping;
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import static org.hibernate.internal.util.StringHelper.safeInterning;
|
||||
|
||||
/**
|
||||
* Models an identifier (name), which may or may not be quoted.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Identifier implements Comparable<Identifier> {
|
||||
private final String text;
|
||||
private final boolean isQuoted;
|
||||
|
||||
/**
|
||||
* Means to generate an {@link Identifier} instance from its simple text form.
|
||||
* <p>
|
||||
* If passed text is {@code null}, {@code null} is returned.
|
||||
* <p>
|
||||
* If passed text is surrounded in quote markers, the generated Identifier
|
||||
* is considered quoted. Quote markers include back-ticks (`), and
|
||||
* double-quotes (").
|
||||
*
|
||||
* @param text The text form
|
||||
*
|
||||
* @return The identifier form, or {@code null} if text was {@code null}
|
||||
*/
|
||||
public static Identifier toIdentifier(String text) {
|
||||
if ( StringHelper.isEmpty( text ) ) {
|
||||
return null;
|
||||
}
|
||||
final String trimmedText = text.trim();
|
||||
if ( isQuoted( trimmedText ) ) {
|
||||
final String bareName = trimmedText.substring( 1, trimmedText.length() - 1 );
|
||||
return new Identifier( bareName, true );
|
||||
}
|
||||
else {
|
||||
return new Identifier( trimmedText, false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Means to generate an {@link Identifier} instance from its simple text form.
|
||||
* <p>
|
||||
* If passed text is {@code null}, {@code null} is returned.
|
||||
* <p>
|
||||
* If passed text is surrounded in quote markers, the generated Identifier
|
||||
* is considered quoted. Quote markers include back-ticks (`), and
|
||||
* double-quotes (").
|
||||
*
|
||||
* @param text The text form
|
||||
* @param quote Whether to quote unquoted text forms
|
||||
*
|
||||
* @return The identifier form, or {@code null} if text was {@code null}
|
||||
*/
|
||||
public static Identifier toIdentifier(String text, boolean quote) {
|
||||
if ( StringHelper.isEmpty( text ) ) {
|
||||
return null;
|
||||
}
|
||||
final String trimmedText = text.trim();
|
||||
if ( isQuoted( trimmedText ) ) {
|
||||
final String bareName = trimmedText.substring( 1, trimmedText.length() - 1 );
|
||||
return new Identifier( bareName, true );
|
||||
}
|
||||
else {
|
||||
return new Identifier( trimmedText, quote );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given identifier text considered quoted. The following patterns are
|
||||
* recognized as quoted:<ul>
|
||||
* <li>{@code `name`}</li>
|
||||
* <li>{@code [name]}</li>
|
||||
* <li>{@code "name"}</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* That final form using double-quote (") is the JPA-defined quoting pattern. Although
|
||||
* it is the standard, it makes for ugly declarations.
|
||||
*/
|
||||
public static boolean isQuoted(String name) {
|
||||
return ( name.startsWith( "`" ) && name.endsWith( "`" ) )
|
||||
|| ( name.startsWith( "[" ) && name.endsWith( "]" ) )
|
||||
|| ( name.startsWith( "\"" ) && name.endsWith( "\"" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an identifier instance.
|
||||
*
|
||||
* @param text The identifier text.
|
||||
* @param quoted Is this a quoted identifier?
|
||||
*/
|
||||
public Identifier(String text, boolean quoted) {
|
||||
if ( StringHelper.isEmpty( text ) ) {
|
||||
throw new IllegalIdentifierException( "Identifier text cannot be null" );
|
||||
}
|
||||
if ( isQuoted( text ) ) {
|
||||
throw new IllegalIdentifierException( "Identifier text should not contain quote markers (` or \")" );
|
||||
}
|
||||
this.text = text;
|
||||
this.isQuoted = quoted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the identifiers name (text)
|
||||
*
|
||||
* @return The name
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a quoted identifier>
|
||||
*
|
||||
* @return True if this is a quote identifier; false otherwise.
|
||||
*/
|
||||
public boolean isQuoted() {
|
||||
return isQuoted;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a quoted identifier, then return the identifier name
|
||||
* enclosed in dialect-specific open- and end-quotes; otherwise,
|
||||
* simply return the unquoted identifier.
|
||||
*
|
||||
* @param dialect The dialect whose dialect-specific quoting should be used.
|
||||
*
|
||||
* @return if quoted, identifier name enclosed in dialect-specific open- and
|
||||
* end-quotes; otherwise, the unquoted identifier.
|
||||
*/
|
||||
public String render(Dialect dialect) {
|
||||
return safeInterning(
|
||||
isQuoted
|
||||
? dialect.openQuote() + getText() + dialect.closeQuote()
|
||||
: getText()
|
||||
);
|
||||
}
|
||||
|
||||
public String render() {
|
||||
return safeInterning( isQuoted ? '`' + getText() + '`' : getText() );
|
||||
}
|
||||
|
||||
public String getCanonicalName() {
|
||||
return isQuoted ? text : text.toLowerCase( Locale.ENGLISH );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( !(o instanceof Identifier) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Identifier that = (Identifier) o;
|
||||
return getCanonicalName().equals( that.getCanonicalName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return isQuoted ? text.hashCode() : text.toLowerCase( Locale.ENGLISH ).hashCode();
|
||||
}
|
||||
|
||||
public static boolean areEqual(Identifier id1, Identifier id2) {
|
||||
if ( id1 == null ) {
|
||||
return id2 == null;
|
||||
}
|
||||
else {
|
||||
return id1.equals( id2 );
|
||||
}
|
||||
}
|
||||
|
||||
public static Identifier quote(Identifier identifier) {
|
||||
return identifier.isQuoted()
|
||||
? identifier
|
||||
: Identifier.toIdentifier( identifier.getText(), true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Identifier o) {
|
||||
return getCanonicalName().compareTo( o.getCanonicalName() );
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
||||
/**
|
||||
* Indicates an attempted use of a name that was deemed illegal
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class IllegalIdentifierException extends HibernateException {
|
||||
public IllegalIdentifierException(String s) {
|
||||
super( s );
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
/**
|
||||
* Support for Hibernate's {@link org.hibernate.annotations.Subselect} feature
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class InlineView implements Table {
|
||||
private final String query;
|
||||
|
||||
public InlineView(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableExpression() {
|
||||
return getQuery();
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
|
||||
/**
|
||||
* A column physically defined in the database table or inline-view
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PhysicalColumn implements Column {
|
||||
private final Table table;
|
||||
private final Identifier columnName;
|
||||
private final JdbcMapping jdbcMapping;
|
||||
|
||||
public PhysicalColumn(Table table, Identifier columnName, JdbcMapping jdbcMapping) {
|
||||
this.table = table;
|
||||
this.columnName = columnName;
|
||||
this.jdbcMapping = jdbcMapping;
|
||||
}
|
||||
|
||||
public Identifier getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnExpression() {
|
||||
return getColumnName().render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
return jdbcMapping;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
/**
|
||||
* A table (or view, etc) that is physically defined on the database.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PhysicalTable implements Table {
|
||||
private final Identifier catalogName;
|
||||
private final Identifier schemaName;
|
||||
private final Identifier tableName;
|
||||
|
||||
public PhysicalTable(
|
||||
Identifier catalogName,
|
||||
Identifier schemaName,
|
||||
Identifier tableName) {
|
||||
this.catalogName = catalogName;
|
||||
this.schemaName = schemaName;
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Identifier getCatalogName() {
|
||||
return catalogName;
|
||||
}
|
||||
|
||||
public Identifier getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
public Identifier getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableExpression() {
|
||||
return getTableName().render();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class RuntimeRelationModelHelper {
|
||||
public static final String DEFAULT_COLUMN_WRITE_EXPRESSION = "?";
|
||||
|
||||
private RuntimeRelationModelHelper() {
|
||||
// disallow direct instantiation
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.relational;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Table {
|
||||
String getTableExpression();
|
||||
}
|
Loading…
Reference in New Issue