Top Description Fields Constructors Methods
org.eclipse.persistence.internal.helper

public Class DatabaseField

extends Object
implements Cloneable, Serializable, CoreField
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.internal.core.helper.CoreField, java.io.Serializable, java.lang.Cloneable
Known Direct Subclasses
org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField, org.eclipse.persistence.oxm.XMLField, org.eclipse.persistence.internal.helper.FunctionField
Imports
java.io.Serializable, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.internal.core.helper.CoreField, org.eclipse.persistence.internal.databaseaccess.DatabasePlatform, .DatasourcePlatform, org.eclipse.persistence.internal.security.PrivilegedAccessHelper

INTERNAL:

Purpose: Define a fully qualified field name.

Responsibilities:

See Also
DatabaseTable

Field Summary

Modifier and TypeField and Description
protected String
public int
index

Store normal index of field in result set to optimize performance.

protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
isTranslated

Returns true if this field was translated.

protected boolean
protected boolean
public boolean
keepInRow

Indicates whether the field should be kept in the record after the object is created.

protected int
protected String
name

Column name of the field.

protected String
nameForComparisons

If this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.

public static final int
NULL_SQL_TYPE

used to represent the value when it has not being defined

protected int
protected String
qualifiedName

PERF: Cache fully qualified table.field-name.

protected int
scale

Variables used for generating DDL

public int
sqlType

Respective JDBC type of the field's value.

protected DatabaseTable
table

Fields table (encapsulates name + creator).

public transient Class<?>
type

Respective Java type desired for the field's value, used to optimize performance and for binding.

public String
protected boolean
protected boolean
useUpperCaseForComparisons

setting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase().

Constructor Summary

AccessConstructor and Description
public
public
DatabaseField(String qualifiedName)

public
DatabaseField(String qualifiedName, String startDelimiter, String endDelimiter)

public
DatabaseField(String fieldName, String tableName)

public
DatabaseField(String fieldName, DatabaseTable databaseTable)

public
DatabaseField(String fieldName, DatabaseTable databaseTable, String startDelimiter, String endDelimiter)

Method Summary

Modifier and TypeMethod and Description
public DatabaseField
clone()

Overrides java.lang.Object.clone.

The table is not cloned because it is treated as an automatic value.
public void
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Determine whether the receiver is equal to a DatabaseField.
public boolean
equals(DatabaseField field)

Determine whether the receiver is equal to a DatabaseField.

public String
getColumnDefinition()

Get the SQL fragment that is used when generating the DDL for the column.

public int
getIndex()

Return the expected index that this field will occur in the result set row.

public int
getLength()

Used to specify the column length when generating DDL.

public String
getName()

Implements org.eclipse.persistence.internal.core.helper.CoreField.getName.

Return the unqualified name of the field.
public String
getNameDelimited(DatasourcePlatform platform)

Returns this fields name with database delimiters if useDelimiters is true.

public String
getNameForComparisons()

INTERNAL: gets the string used for comparisons and in determining the hashcode.

public int
getPrecision()

Returns the precision for a decimal column when generating DDL.

public String
public String
getQualifiedNameDelimited(DatasourcePlatform platform)

Return the qualified name of the field.

public int
getScale()

Returns the scale for a decimal column when generating DDL.

public int
getSqlType()

Return the JDBC type that corresponds to the field.

public DatabaseTable
public String
public Class<?>
public String
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Return the hashcode of the name, because it is fairly unique.
public boolean
public void
initDDLFields()

Inits the DDL generation fields with our defaults.

public boolean
public boolean
isInsertable()

Used to specify whether the column should be included in SQL UPDATE statements.

public boolean
isNullable()

Used for generating DDL.

public boolean
isObjectRelationalDatabaseField()

PUBLIC: Return if this is an ObjectRelationalDatabaseField.

public boolean
isPrimaryKey()

Used to specify whether the column should be included in the primary on the database table.

public boolean
isReadOnly()

Returns true is this database field should be read only.

public boolean
isTranslated()

Return true if this database field is a translation.

public boolean
isUnique()

Used for generating DDL.

public boolean
isUpdatable()

Returns whether the column should be included in SQL INSERT statements.

public boolean
public void
resetQualifiedName(String qualifiedName)

Reset the field's name and table from the qualified name.

public void
setColumnDefinition(String columnDefinition)

Set the SQL fragment that is used when generating the DDL for the column.

public void
setCreatable(boolean isCreatable)

public void
setIndex(int index)

Set the expected index that this field will occur in the result set row.

public void
setInsertable(boolean isInsertable)

Used to specify whether the column should be included in SQL UPDATE statements.

public void
setIsTranslated(boolean isTranslated)

Set the isTranslated flag.

public void
setKeepInRow(boolean keepInRow)

public void
setLength(int length)

Used to specify the column length when generating DDL.

public void
setName(String name)

Implements org.eclipse.persistence.internal.core.helper.CoreField.setName.

Set the unqualified name of the field.
public void
setName(String name, DatasourcePlatform platform)

Set the unqualified name of the field.

public void
setName(String name, String startDelimiter, String endDelimiter)

Set the unqualified name of the field.

public void
setNameForComparisons(String name)

INTERNAL: sets the string to be used for equality checking and determining the hashcode of this field.

public void
setNullable(boolean isNullable)

Used for generating DDL.

public void
setPrecision(int precision)

Used to specify the precision for a decimal column when generating DDL.

public void
setPrimaryKey(boolean isPrimaryKey)

Used to specify whether the column should be included in primary key on the database table.

public void
setScale(int scale)

Used to specify the scale for a decimal column when generating DDL.

public void
setSqlType(int sqlType)

Set the JDBC type that corresponds to the field.

public void
setTable(DatabaseTable table)

Set the table for the field.

public void
setTableName(String tableName)

public void
setType(Class<?> type)

Implements org.eclipse.persistence.internal.core.helper.CoreField.setType.

Set the Java class type that corresponds to the field.
public void
setTypeName(String typeName)

public void
setUnique(boolean isUnique)

Used for generating DDL.

public void
setUpdatable(boolean isUpdatable)

Used to specify whether the column should be included in SQL INSERT statements.

public void
setUseDelimiters(boolean useDelimiters)

public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
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.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

columnDefinitionback to summary
protected String columnDefinition
indexback to summary
public int index

Store normal index of field in result set to optimize performance. PERF: Allow direct variable access from getIndicatingNoEntry.

isCreatableback to summary
protected boolean isCreatable
isInsertableback to summary
protected boolean isInsertable
isNullableback to summary
protected boolean isNullable
isPrimaryKeyback to summary
protected boolean isPrimaryKey
isTranslatedback to summary
protected boolean isTranslated

Returns true if this field was translated.

isUniqueback to summary
protected boolean isUnique
isUpdatableback to summary
protected boolean isUpdatable
keepInRowback to summary
public boolean keepInRow

Indicates whether the field should be kept in the record after the object is created. Used by ObjectLevelReadQuery ResultSetAccessOptimization.

lengthback to summary
protected int length
nameback to summary
protected String name

Column name of the field.

nameForComparisonsback to summary
protected String nameForComparisons

If this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.

See Also
getNameForComparisons()
NULL_SQL_TYPEback to summary
public static final int NULL_SQL_TYPE

used to represent the value when it has not being defined

precisionback to summary
protected int precision
qualifiedNameback to summary
protected String qualifiedName

PERF: Cache fully qualified table.field-name.

scaleback to summary
protected int scale

Variables used for generating DDL

sqlTypeback to summary
public int sqlType

Respective 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.

tableback to summary
protected DatabaseTable table

Fields table (encapsulates name + creator).

typeback to summary
public transient Class<?> type

Respective Java type desired for the field's value, used to optimize performance and for binding. PERF: Allow direct variable access from getObject.

typeNameback to summary
public String typeName
useDelimitersback to summary
protected boolean useDelimiters
useUpperCaseForComparisonsback to summary
protected boolean useUpperCaseForComparisons

setting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase().

Constructor Detail

DatabaseFieldback to summary
public DatabaseField()
DatabaseFieldback to summary
public DatabaseField(String qualifiedName)
DatabaseFieldback to summary
public DatabaseField(String qualifiedName, String startDelimiter, String endDelimiter)
DatabaseFieldback to summary
public DatabaseField(String fieldName, String tableName)
DatabaseFieldback to summary
public DatabaseField(String fieldName, DatabaseTable databaseTable)
DatabaseFieldback to summary
public DatabaseField(String fieldName, DatabaseTable databaseTable, String startDelimiter, String endDelimiter)

Method Detail

cloneback to summary
public DatabaseField clone()

Overrides java.lang.Object.clone.

The table is not cloned because it is treated as an automatic value.

Returns:DatabaseField

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
convertClassNamesToClassesback to summary
public void convertClassNamesToClasses(ClassLoader classLoader)
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.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.

Parameters
object:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalsback to summary
public boolean equals(DatabaseField field)

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.

getColumnDefinitionback to summary
public String getColumnDefinition()

Get the SQL fragment that is used when generating the DDL for the column.

getIndexback to summary
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.

getLengthback to summary
public int getLength()

Used to specify the column length when generating DDL.

getNameback to summary
public String getName()

Implements org.eclipse.persistence.internal.core.helper.CoreField.getName.

Return the unqualified name of the field.

Annotations
@Override
getNameDelimitedback to summary
public String getNameDelimited(DatasourcePlatform platform)

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.

getNameForComparisonsback to summary
public String getNameForComparisons()

INTERNAL: gets the string used for comparisons and in determining the hashcode.

getPrecisionback to summary
public int getPrecision()

Returns the precision for a decimal column when generating DDL.

getQualifiedNameback to summary
public String getQualifiedName()
getQualifiedNameDelimitedback to summary
public String getQualifiedNameDelimited(DatasourcePlatform platform)

Return the qualified name of the field. PERF: Cache the qualified name.

getScaleback to summary
public int getScale()

Returns the scale for a decimal column when generating DDL.

getSqlTypeback to summary
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.

getTableback to summary
public DatabaseTable getTable()
getTableNameback to summary
public String getTableName()
getTypeback to summary
public Class<?> getType()

Implements org.eclipse.persistence.internal.core.helper.CoreField.getType.

Annotations
@Override
getTypeNameback to summary
public String getTypeName()
getUseUpperCaseForComparisonsback to summary
public boolean getUseUpperCaseForComparisons()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return the hashcode of the name, because it is fairly unique.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
hasTableNameback to summary
public boolean hasTableName()
initDDLFieldsback to summary
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.

isCreatableback to summary
public boolean isCreatable()
isInsertableback to summary
public boolean isInsertable()

Used to specify whether the column should be included in SQL UPDATE statements.

isNullableback to summary
public boolean isNullable()

Used for generating DDL. Returns true if the database column is nullable.

isObjectRelationalDatabaseFieldback to summary
public boolean isObjectRelationalDatabaseField()

PUBLIC: Return if this is an ObjectRelationalDatabaseField.

isPrimaryKeyback to summary
public boolean isPrimaryKey()

Used to specify whether the column should be included in the primary on the database table.

isReadOnlyback to summary
public boolean isReadOnly()

Returns true is this database field should be read only.

isTranslatedback to summary
public boolean isTranslated()

Return true if this database field is a translation.

isUniqueback to summary
public boolean isUnique()

Used for generating DDL. Returns true if the field is a unique key.

isUpdatableback to summary
public boolean isUpdatable()

Returns whether the column should be included in SQL INSERT statements.

keepInRowback to summary
public boolean keepInRow()
resetQualifiedNameback to summary
public void resetQualifiedName(String qualifiedName)

Reset the field's name and table from the qualified name.

setColumnDefinitionback to summary
public void setColumnDefinition(String columnDefinition)

Set the SQL fragment that is used when generating the DDL for the column.

setCreatableback to summary
public void setCreatable(boolean isCreatable)
setIndexback to summary
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.

setInsertableback to summary
public void setInsertable(boolean isInsertable)

Used to specify whether the column should be included in SQL UPDATE statements.

setIsTranslatedback to summary
public void setIsTranslated(boolean isTranslated)

Set the isTranslated flag.

setKeepInRowback to summary
public void setKeepInRow(boolean keepInRow)
setLengthback to summary
public void setLength(int length)

Used to specify the column length when generating DDL.

setNameback to summary
public void setName(String name)

Implements org.eclipse.persistence.internal.core.helper.CoreField.setName.

Set the unqualified name of the field.

Annotations
@Override
setNameback to summary
public void setName(String name, DatasourcePlatform platform)

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

setNameback to summary
public void setName(String name, String startDelimiter, String endDelimiter)

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

setNameForComparisonsback to summary
public void setNameForComparisons(String name)

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.

setNullableback to summary
public void setNullable(boolean isNullable)

Used for generating DDL. Set to true if the database column is nullable.

setPrecisionback to summary
public void setPrecision(int precision)

Used to specify the precision for a decimal column when generating DDL.

setPrimaryKeyback to summary
public void setPrimaryKey(boolean isPrimaryKey)

Used to specify whether the column should be included in primary key on the database table.

setScaleback to summary
public void setScale(int scale)

Used to specify the scale for a decimal column when generating DDL.

setSqlTypeback to summary
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.

setTableback to summary
public void setTable(DatabaseTable table)

Set the table for the field.

setTableNameback to summary
public void setTableName(String tableName)
setTypeback to summary
public void setType(Class<?> type)

Implements org.eclipse.persistence.internal.core.helper.CoreField.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.

Annotations
@Override
setTypeNameback to summary
public void setTypeName(String typeName)
setUniqueback to summary
public void setUnique(boolean isUnique)

Used for generating DDL. Set to true if the field is a unique key.

setUpdatableback to summary
public void setUpdatable(boolean isUpdatable)

Used to specify whether the column should be included in SQL INSERT statements.

setUseDelimitersback to summary
public void setUseDelimiters(boolean useDelimiters)
shouldUseDelimitersback to summary
public boolean shouldUseDelimiters()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
useUpperCaseForComparisonsback to summary
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.