Module org.eclipse.persistence.core
Class DatabaseField
java.lang.Object
org.eclipse.persistence.internal.helper.DatabaseField
- All Implemented Interfaces:
Serializable,Cloneable,CoreField
- Direct Known Subclasses:
FunctionField,ObjectRelationalDatabaseField,XMLField
INTERNAL:
Purpose: Define a fully qualified field name.
Responsibilities:
- Know its name and its table.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringintStore normal index of field in result set to optimize performance.protected booleanprotected booleanprotected booleanprotected booleanprotected booleanReturns true if this field was translated.protected booleanprotected booleanbooleanIndicates whether the field should be kept in the record after the object is created.protected intprotected StringColumn name of the field.protected StringIf this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.static final intused to represent the value when it has not being definedprotected intprotected StringPERF: Cache fully qualified table.field-name.protected intVariables used for generating DDLintRespective JDBC type of the field's value.protected DatabaseTableFields table (encapsulates name + creator).Class<?> Respective Java type desired for the field's value, used to optimize performance and for binding.protected booleanprotected booleansetting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase(). -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseField(String qualifiedName) DatabaseField(String fieldName, String tableName) DatabaseField(String qualifiedName, String startDelimiter, String endDelimiter) DatabaseField(String fieldName, DatabaseTable databaseTable) DatabaseField(String fieldName, DatabaseTable databaseTable, String startDelimiter, String endDelimiter) -
Method Summary
Modifier and TypeMethodDescriptionclone()The table is not cloned because it is treated as an automatic value.voidconvertClassNamesToClasses(ClassLoader classLoader) booleanDetermine whether the receiver is equal to a DatabaseField.booleanequals(DatabaseField field) Determine whether the receiver is equal to a DatabaseField.Get the SQL fragment that is used when generating the DDL for the column.intgetIndex()Return the expected index that this field will occur in the result set row.intUsed to specify the column length when generating DDL.getName()Return the unqualified name of the field.getNameDelimited(DatasourcePlatform platform) Returns this fields name with database delimiters if useDelimiters is true.INTERNAL: gets the string used for comparisons and in determining the hashcode.intReturns the precision for a decimal column when generating DDL.getQualifiedNameDelimited(DatasourcePlatform platform) Return the qualified name of the field.intgetScale()Returns the scale for a decimal column when generating DDL.intReturn the JDBC type that corresponds to the field.getTable()Class<?> getType()booleaninthashCode()Return the hashcode of the name, because it is fairly unique.booleanvoidInits the DDL generation fields with our defaults.booleanbooleanUsed to specify whether the column should be included in SQL UPDATE statements.booleanUsed for generating DDL.booleanPUBLIC: Return if this is an ObjectRelationalDatabaseField.booleanUsed to specify whether the column should be included in the primary on the database table.booleanReturns true is this database field should be read only.booleanReturn true if this database field is a translation.booleanisUnique()Used for generating DDL.booleanReturns whether the column should be included in SQL INSERT statements.booleanvoidresetQualifiedName(String qualifiedName) Reset the field's name and table from the qualified name.voidsetColumnDefinition(String columnDefinition) Set the SQL fragment that is used when generating the DDL for the column.voidsetCreatable(boolean isCreatable) voidsetIndex(int index) Set the expected index that this field will occur in the result set row.voidsetInsertable(boolean isInsertable) Used to specify whether the column should be included in SQL UPDATE statements.voidsetIsTranslated(boolean isTranslated) Set the isTranslated flag.voidsetKeepInRow(boolean keepInRow) voidsetLength(int length) Used to specify the column length when generating DDL.voidSet the unqualified name of the field.voidSet the unqualified name of the field.voidsetName(String name, DatasourcePlatform platform) Set the unqualified name of the field.voidsetNameForComparisons(String name) INTERNAL: sets the string to be used for equality checking and determining the hashcode of this field.voidsetNullable(boolean isNullable) Used for generating DDL.voidsetPrecision(int precision) Used to specify the precision for a decimal column when generating DDL.voidsetPrimaryKey(boolean isPrimaryKey) Used to specify whether the column should be included in primary key on the database table.voidsetScale(int scale) Used to specify the scale for a decimal column when generating DDL.voidsetSqlType(int sqlType) Set the JDBC type that corresponds to the field.voidsetTable(DatabaseTable table) Set the table for the field.voidsetTableName(String tableName) voidSet the Java class type that corresponds to the field.voidsetTypeName(String typeName) voidsetUnique(boolean isUnique) Used for generating DDL.voidsetUpdatable(boolean isUpdatable) Used to specify whether the column should be included in SQL INSERT statements.voidsetUseDelimiters(boolean useDelimiters) booleantoString()voiduseUpperCaseForComparisons(boolean useUpperCaseForComparisons) INTERNAL: Sets the useUpperCaseForComparisons flag which is used to force using the uppercase version of the field's name to determine field equality and its hashcode, but will still use the original name when writing/printing operations.
-
Field Details
-
scale
protected int scaleVariables used for generating DDL -
length
protected int length -
precision
protected int precision -
isUnique
protected boolean isUnique -
isNullable
protected boolean isNullable -
isUpdatable
protected boolean isUpdatable -
isInsertable
protected boolean isInsertable -
isCreatable
protected boolean isCreatable -
isPrimaryKey
protected boolean isPrimaryKey -
columnDefinition
-
name
Column name of the field. -
qualifiedName
PERF: Cache fully qualified table.field-name. -
table
Fields table (encapsulates name + creator). -
type
Respective Java type desired for the field's value, used to optimize performance and for binding. PERF: Allow direct variable access from getObject. -
typeName
-
sqlType
public int sqlTypeRespective JDBC type of the field's value. This overrides the class type, which the JDBC type is normally computed from. PERF: Allow direct variable access from getObject. -
index
public int indexStore normal index of field in result set to optimize performance. PERF: Allow direct variable access from getIndicatingNoEntry. -
useDelimiters
protected boolean useDelimiters -
nameForComparisons
If this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.- See Also:
-
useUpperCaseForComparisons
protected boolean useUpperCaseForComparisonssetting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase(). -
NULL_SQL_TYPE
public static final int NULL_SQL_TYPEused to represent the value when it has not being defined- See Also:
-
isTranslated
protected boolean isTranslatedReturns true if this field was translated. -
keepInRow
public boolean keepInRowIndicates whether the field should be kept in the record after the object is created. Used by ObjectLevelReadQuery ResultSetAccessOptimization.
-
-
Constructor Details
-
DatabaseField
public DatabaseField() -
DatabaseField
-
DatabaseField
-
DatabaseField
-
DatabaseField
-
DatabaseField
public DatabaseField(String fieldName, DatabaseTable databaseTable, String startDelimiter, String endDelimiter)
-
-
Method Details
-
initDDLFields
public void initDDLFields()Inits the DDL generation fields with our defaults. Note: we used to initialize the length to the JPA default of 255 but since this default value should only apply for string fields we set it to 0 to indicate that it was not specified and rely on the default (255) to come from individual platforms. -
clone
The table is not cloned because it is treated as an automatic value. -
convertClassNamesToClasses
-
equals
Determine whether the receiver is equal to a DatabaseField. Return true if the receiver and field have the same name and table. Also return true if the table of the receiver or field are unspecified, ie. have no name. -
equals
Determine whether the receiver is equal to a DatabaseField. Return true if the receiver and field have the same name and table. Also return true if the table of the receiver or field are unspecified, ie. have no name. -
getColumnDefinition
Get the SQL fragment that is used when generating the DDL for the column. -
getIndex
public int getIndex()Return the expected index that this field will occur in the result set row. This is used to optimize performance of database row field lookups. -
getLength
public int getLength()Used to specify the column length when generating DDL. -
getName
Return the unqualified name of the field. -
getNameDelimited
Returns this fields name with database delimiters if useDelimiters is true. This method should be called any time the field name is requested for writing SQL. -
getPrecision
public int getPrecision()Returns the precision for a decimal column when generating DDL. -
getQualifiedName
-
getQualifiedNameDelimited
Return the qualified name of the field. PERF: Cache the qualified name. -
getScale
public int getScale()Returns the scale for a decimal column when generating DDL. -
getTable
-
getTableName
-
setTableName
-
getType
-
getTypeName
-
setTypeName
-
getSqlType
public int getSqlType()Return the JDBC type that corresponds to the field. The JDBC type is normally determined from the class type, but this allows it to be overridden for types that do not match directly to a Java type, such as MONEY or ARRAY, STRUCT, XMLTYPE, etc. This can be used for binding or stored procedure usage. -
hashCode
public int hashCode()Return the hashcode of the name, because it is fairly unique. -
hasTableName
public boolean hasTableName() -
isObjectRelationalDatabaseField
public boolean isObjectRelationalDatabaseField()PUBLIC: Return if this is an ObjectRelationalDatabaseField. -
isInsertable
public boolean isInsertable()Used to specify whether the column should be included in SQL UPDATE statements. -
isNullable
public boolean isNullable()Used for generating DDL. Returns true if the database column is nullable. -
isPrimaryKey
public boolean isPrimaryKey()Used to specify whether the column should be included in the primary on the database table. -
isTranslated
public boolean isTranslated()Return true if this database field is a translation. -
isUnique
public boolean isUnique()Used for generating DDL. Returns true if the field is a unique key. -
isReadOnly
public boolean isReadOnly()Returns true is this database field should be read only. -
keepInRow
public boolean keepInRow() -
isUpdatable
public boolean isUpdatable()Returns whether the column should be included in SQL INSERT statements. -
resetQualifiedName
Reset the field's name and table from the qualified name. -
setColumnDefinition
Set the SQL fragment that is used when generating the DDL for the column. -
setIndex
public void setIndex(int index) Set the expected index that this field will occur in the result set row. This is used to optimize performance of database row field lookups. -
setInsertable
public void setInsertable(boolean isInsertable) Used to specify whether the column should be included in SQL UPDATE statements. -
setKeepInRow
public void setKeepInRow(boolean keepInRow) -
setIsTranslated
public void setIsTranslated(boolean isTranslated) Set the isTranslated flag. -
setLength
public void setLength(int length) Used to specify the column length when generating DDL. -
setName
Set the unqualified name of the field. -
setName
Set the unqualified name of the field. If the name contains database delimiters, they will be stripped and a flag will be set to have them added when the DatabaseField is written to SQL -
setName
Set the unqualified name of the field. If the name contains database delimiters, they will be stripped and a flag will be set to have them added when the DatabaseField is written to SQL -
setNullable
public void setNullable(boolean isNullable) Used for generating DDL. Set to true if the database column is nullable. -
setPrecision
public void setPrecision(int precision) Used to specify the precision for a decimal column when generating DDL. -
setPrimaryKey
public void setPrimaryKey(boolean isPrimaryKey) Used to specify whether the column should be included in primary key on the database table. -
setScale
public void setScale(int scale) Used to specify the scale for a decimal column when generating DDL. -
setSqlType
public void setSqlType(int sqlType) Set the JDBC type that corresponds to the field. The JDBC type is normally determined from the class type, but this allows it to be overridden for types that do not match directly to a Java type, such as MONEY or ARRAY, STRUCT, XMLTYPE, etc. This can be used for binding or stored procedure usage. -
setTable
Set the table for the field. -
setType
Set the Java class type that corresponds to the field. The JDBC type is determined from the class type, this is used to optimize performance, and for binding. -
setUnique
public void setUnique(boolean isUnique) Used for generating DDL. Set to true if the field is a unique key. -
setUpdatable
public void setUpdatable(boolean isUpdatable) Used to specify whether the column should be included in SQL INSERT statements. -
toString
-
setUseDelimiters
public void setUseDelimiters(boolean useDelimiters) -
shouldUseDelimiters
public boolean shouldUseDelimiters() -
useUpperCaseForComparisons
public void useUpperCaseForComparisons(boolean useUpperCaseForComparisons) INTERNAL: Sets the useUpperCaseForComparisons flag which is used to force using the uppercase version of the field's name to determine field equality and its hashcode, but will still use the original name when writing/printing operations. If this isn't a change, it is ignored, otherwise it sets the nameForComparisons to null. -
getUseUpperCaseForComparisons
public boolean getUseUpperCaseForComparisons() -
setNameForComparisons
INTERNAL: sets the string to be used for equality checking and determining the hashcode of this field. This will overwrite the useUpperCaseForEquality setting with the passed in string. -
isCreatable
public boolean isCreatable() -
setCreatable
public void setCreatable(boolean isCreatable) -
getNameForComparisons
INTERNAL: gets the string used for comparisons and in determining the hashcode.
-