Class DatabaseTable
- java.lang.Object
-
- org.eclipse.persistence.internal.helper.DatabaseTable
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,CoreTable
- Direct Known Subclasses:
DecoratedDatabaseTable,HistoricalDatabaseTable,NestedTable,SubSelectDatabaseTable
public class DatabaseTable extends java.lang.Object implements CoreTable, java.lang.Cloneable, java.io.Serializable
INTERNAL:Purpose: Define a fully qualified table name.
Responsibilities:
- Allow specification of a qualifier to the table, i.e. creator or database.
- See Also:
DatabaseField, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringcreationSuffixprotected java.util.Map<java.lang.String,ForeignKeyConstraint>foreignKeyConstraintsJPA 2.1 Foreign key specification dataprotected java.util.List<IndexDefinition>indexesStore the set of indexes defined through meta-data for the table.protected java.lang.Stringnameprotected java.lang.StringqualifiedNameprotected java.lang.StringtableQualifierprotected java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>>uniqueConstraintsContains the user specified unique constraints.protected booleanuseDelimiters
-
Constructor Summary
Constructors Constructor Description DatabaseTable()Initialize the newly allocated instance of this class.DatabaseTable(java.lang.String possiblyQualifiedName)DatabaseTable(java.lang.String tableName, java.lang.String qualifier)DatabaseTable(java.lang.String tableName, java.lang.String qualifier, boolean useDelimiters, java.lang.String startDelimiter, java.lang.String endDelimiter)DatabaseTable(java.lang.String possiblyQualifiedName, java.lang.String startDelimiter, java.lang.String endDelimiter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint)voidaddIndex(IndexDefinition index)Add an index definition to this table.voidaddUniqueConstraints(java.lang.String name, java.util.List<java.lang.String> columnNames)Add the unique constraint for the columns names.DatabaseTableclone()Return a shallow copy of the receiver.booleanequals(java.lang.Object object)Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned.booleanequals(DatabaseTable table)Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned.java.lang.StringgetCreationSuffix()returns the suffix applied to the CREATE table statement on this field for DDL generation.ForeignKeyConstraintgetForeignKeyConstraint(java.lang.String name)java.util.Map<java.lang.String,ForeignKeyConstraint>getForeignKeyConstraints()java.util.List<IndexDefinition>getIndexes()Return a list of index definitions.java.lang.StringgetName()Get method for table name.java.lang.StringgetNameDelimited(DatasourcePlatform platform)Get method for table name.java.lang.StringgetQualifiedName()java.lang.StringgetQualifiedNameDelimited(DatasourcePlatform platform)java.lang.StringgetTableQualifier()java.lang.StringgetTableQualifierDelimited(DatasourcePlatform platform)java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>>getUniqueConstraints()Return a list of the unique constraints for this table.booleanhasForeignKeyConstraints()inthashCode()Return the hashcode of the name, because it is fairly unique.booleanhasIndexes()booleanhasName()Determine whether the receiver has any identification information.booleanhasUniqueConstraints()booleanisDecorated()INTERNAL: Is this decorated / has an AS OF (some past time) clause.voidprintSQL(ExpressionSQLPrinter printer)Print the table's SQL from clause.protected voidresetQualifiedName()voidsetCreationSuffix(java.lang.String creationSuffix)voidsetName(java.lang.String name)Set the table name.voidsetName(java.lang.String name, java.lang.String startDelimiter, java.lang.String endDelimiter)Set the table name.voidsetPossiblyQualifiedName(java.lang.String possiblyQualifiedName)Used to map the project xml.voidsetPossiblyQualifiedName(java.lang.String possiblyQualifiedName, java.lang.String startDelimiter, java.lang.String endDelimiter)voidsetTableQualifier(java.lang.String qualifier)voidsetTableQualifier(java.lang.String qualifier, java.lang.String startDelimiter, java.lang.String endDelimiter)voidsetUseDelimiters(boolean useDelimiters)booleanshouldUseDelimiters()java.lang.StringtoString()
-
-
-
Field Detail
-
name
protected java.lang.String name
-
tableQualifier
protected java.lang.String tableQualifier
-
qualifiedName
protected java.lang.String qualifiedName
-
foreignKeyConstraints
protected java.util.Map<java.lang.String,ForeignKeyConstraint> foreignKeyConstraints
JPA 2.1 Foreign key specification data
-
uniqueConstraints
protected java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> uniqueConstraints
Contains the user specified unique constraints. JPA 2.0 introduced the name element, therefore, if specified we will use that name to create the constraint. Constraints with no name will be added to the map under the null key and generated with a default name. Therefore, when a name is given the list size should only ever be 1. We will validate. The null key could have multiples however they will have their names defaulted (as we did before).
-
indexes
protected java.util.List<IndexDefinition> indexes
Store the set of indexes defined through meta-data for the table.
-
useDelimiters
protected boolean useDelimiters
-
creationSuffix
protected java.lang.String creationSuffix
-
-
Constructor Detail
-
DatabaseTable
public DatabaseTable()
Initialize the newly allocated instance of this class. By default their is no qualifier.
-
DatabaseTable
public DatabaseTable(java.lang.String possiblyQualifiedName)
-
DatabaseTable
public DatabaseTable(java.lang.String possiblyQualifiedName, java.lang.String startDelimiter, java.lang.String endDelimiter)
-
DatabaseTable
public DatabaseTable(java.lang.String tableName, java.lang.String qualifier)
-
DatabaseTable
public DatabaseTable(java.lang.String tableName, java.lang.String qualifier, boolean useDelimiters, java.lang.String startDelimiter, java.lang.String endDelimiter)
-
-
Method Detail
-
addForeignKeyConstraint
public void addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint)
-
addIndex
public void addIndex(IndexDefinition index)
Add an index definition to this table.
-
addUniqueConstraints
public void addUniqueConstraints(java.lang.String name, java.util.List<java.lang.String> columnNames)Add the unique constraint for the columns names. Used for DDL generation. For now we just add all the unique constraints as we would have before when we didn't have a name.
-
clone
public DatabaseTable clone()
Return a shallow copy of the receiver.- Overrides:
clonein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned. This allows an unqualified table to equal the same fully qualified one.- Overrides:
equalsin classjava.lang.Object
-
equals
public boolean equals(DatabaseTable table)
Two tables are equal if their names and tables are equal, or their names are equal and one does not have a qualifier assigned. This allows an unqualified table to equal the same fully qualified one.
-
getCreationSuffix
public java.lang.String getCreationSuffix()
returns the suffix applied to the CREATE table statement on this field for DDL generation.
-
getForeignKeyConstraint
public ForeignKeyConstraint getForeignKeyConstraint(java.lang.String name)
-
getForeignKeyConstraints
public java.util.Map<java.lang.String,ForeignKeyConstraint> getForeignKeyConstraints()
-
getIndexes
public java.util.List<IndexDefinition> getIndexes()
Return a list of index definitions. Used for DDL generation.
-
getName
public java.lang.String getName()
Get method for table name.
-
getNameDelimited
public java.lang.String getNameDelimited(DatasourcePlatform platform)
Get method for table name.
-
getQualifiedName
public java.lang.String getQualifiedName()
-
getQualifiedNameDelimited
public java.lang.String getQualifiedNameDelimited(DatasourcePlatform platform)
-
printSQL
public void printSQL(ExpressionSQLPrinter printer) throws java.io.IOException
Print the table's SQL from clause.- Throws:
java.io.IOException
-
getTableQualifierDelimited
public java.lang.String getTableQualifierDelimited(DatasourcePlatform platform)
-
getTableQualifier
public java.lang.String getTableQualifier()
-
hasUniqueConstraints
public boolean hasUniqueConstraints()
-
hasForeignKeyConstraints
public boolean hasForeignKeyConstraints()
-
hashCode
public int hashCode()
Return the hashcode of the name, because it is fairly unique.- Overrides:
hashCodein classjava.lang.Object
-
hasIndexes
public boolean hasIndexes()
-
getUniqueConstraints
public java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> getUniqueConstraints()
Return a list of the unique constraints for this table. Used for DDL generation.
-
hasName
public boolean hasName()
Determine whether the receiver has any identification information. Return true if the name or qualifier of the receiver are nonempty.
-
isDecorated
public boolean isDecorated()
INTERNAL: Is this decorated / has an AS OF (some past time) clause. Example: SELECT ... FROM EMPLOYEE AS OF TIMESTAMP (exp) t0 ...
-
resetQualifiedName
protected void resetQualifiedName()
-
setCreationSuffix
public void setCreationSuffix(java.lang.String creationSuffix)
-
setName
public void setName(java.lang.String name)
Set the table name. Used when aliasing table names.- Parameters:
name-
-
setName
public void setName(java.lang.String name, java.lang.String startDelimiter, java.lang.String endDelimiter)Set the table name. Used when aliasing table names. If the name contains database delimiters, they will be stripped and a flag will be set to have them added when the DatabaseTable is written to SQL- Parameters:
name-
-
setPossiblyQualifiedName
public void setPossiblyQualifiedName(java.lang.String possiblyQualifiedName)
Used to map the project xml. Any time a string name is read from the project xml, we must check if it is fully qualified and split the actual name from the qualifier.- Parameters:
possiblyQualifiedName-
-
setPossiblyQualifiedName
public void setPossiblyQualifiedName(java.lang.String possiblyQualifiedName, java.lang.String startDelimiter, java.lang.String endDelimiter)
-
setTableQualifier
public void setTableQualifier(java.lang.String qualifier)
-
setTableQualifier
public void setTableQualifier(java.lang.String qualifier, java.lang.String startDelimiter, java.lang.String endDelimiter)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setUseDelimiters
public void setUseDelimiters(boolean useDelimiters)
-
shouldUseDelimiters
public boolean shouldUseDelimiters()
-
-