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
Modifier and TypeFieldDescriptionprotected String
int
Store normal index of field in result set to optimize performance.protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
Returns true if this field was translated.protected boolean
protected boolean
boolean
Indicates whether the field should be kept in the record after the object is created.protected int
protected String
Column name of the field.protected String
If this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.static final int
used to represent the value when it has not being definedprotected int
protected String
PERF: Cache fully qualified table.field-name.protected int
Variables used for generating DDLint
Respective JDBC type of the field's value.protected DatabaseTable
Fields table (encapsulates name + creator).Class
<?> Respective Java type desired for the field's value, used to optimize performance and for binding.protected boolean
protected boolean
setting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase(). -
Constructor Summary
ConstructorDescriptionDatabaseField
(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.void
convertClassNamesToClasses
(ClassLoader classLoader) boolean
Determine whether the receiver is equal to a DatabaseField.boolean
equals
(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.int
getIndex()
Return the expected index that this field will occur in the result set row.int
Used 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.int
Returns the precision for a decimal column when generating DDL.getQualifiedNameDelimited
(DatasourcePlatform platform) Return the qualified name of the field.int
getScale()
Returns the scale for a decimal column when generating DDL.int
Return the JDBC type that corresponds to the field.getTable()
Class
<?> getType()
boolean
int
hashCode()
Return the hashcode of the name, because it is fairly unique.boolean
void
Inits the DDL generation fields with our defaults.boolean
boolean
Used to specify whether the column should be included in SQL UPDATE statements.boolean
Used for generating DDL.boolean
PUBLIC: Return if this is an ObjectRelationalDatabaseField.boolean
Used to specify whether the column should be included in the primary on the database table.boolean
Returns true is this database field should be read only.boolean
Return true if this database field is a translation.boolean
isUnique()
Used for generating DDL.boolean
Returns whether the column should be included in SQL INSERT statements.boolean
void
resetQualifiedName
(String qualifiedName) Reset the field's name and table from the qualified name.void
setColumnDefinition
(String columnDefinition) Set the SQL fragment that is used when generating the DDL for the column.void
setCreatable
(boolean isCreatable) void
setIndex
(int index) Set the expected index that this field will occur in the result set row.void
setInsertable
(boolean isInsertable) Used to specify whether the column should be included in SQL UPDATE statements.void
setIsTranslated
(boolean isTranslated) Set the isTranslated flag.void
setKeepInRow
(boolean keepInRow) void
setLength
(int length) Used to specify the column length when generating DDL.void
Set the unqualified name of the field.void
Set the unqualified name of the field.void
setName
(String name, DatasourcePlatform platform) Set the unqualified name of the field.void
setNameForComparisons
(String name) INTERNAL: sets the string to be used for equality checking and determining the hashcode of this field.void
setNullable
(boolean isNullable) Used for generating DDL.void
setPrecision
(int precision) Used to specify the precision for a decimal column when generating DDL.void
setPrimaryKey
(boolean isPrimaryKey) Used to specify whether the column should be included in primary key on the database table.void
setScale
(int scale) Used to specify the scale for a decimal column when generating DDL.void
setSqlType
(int sqlType) Set the JDBC type that corresponds to the field.void
setTable
(DatabaseTable table) Set the table for the field.void
setTableName
(String tableName) void
Set the Java class type that corresponds to the field.void
setTypeName
(String typeName) void
setUnique
(boolean isUnique) Used for generating DDL.void
setUpdatable
(boolean isUpdatable) Used to specify whether the column should be included in SQL INSERT statements.void
setUseDelimiters
(boolean useDelimiters) boolean
toString()
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.
-
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.
-