java.lang.Object
org.eclipse.persistence.internal.helper.DatabaseField
All Implemented Interfaces:
Serializable, Cloneable, CoreField
Direct Known Subclasses:
FunctionField, ObjectRelationalDatabaseField, XMLField

public class DatabaseField extends Object implements Cloneable, Serializable, CoreField
INTERNAL:

Purpose: Define a fully qualified field name.

Responsibilities:

  • Know its name and its table.
See Also:
  • Field Details

    • scale

      protected int scale
      Variables 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

      protected String columnDefinition
    • name

      protected String name
      Column name of the field.
    • qualifiedName

      protected String qualifiedName
      PERF: Cache fully qualified table.field-name.
    • table

      protected DatabaseTable table
      Fields table (encapsulates name + creator).
    • type

      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.
    • typeName

      public String typeName
    • sqlType

      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.
    • index

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

      protected boolean useDelimiters
    • nameForComparisons

      protected String nameForComparisons
      If this is set, it will be used in determining equality (unless delimiters are used) and the hashcode.
      See Also:
    • useUpperCaseForComparisons

      protected boolean useUpperCaseForComparisons
      setting to true will cause getNameForComparisons to lazy initialize nameForComparisons using the value from getName().toUpperCase().
    • NULL_SQL_TYPE

      public static final int NULL_SQL_TYPE
      used to represent the value when it has not being defined
      See Also:
    • isTranslated

      protected boolean isTranslated
      Returns true if this field was translated.
    • keepInRow

      public boolean keepInRow
      Indicates whether the field should be kept in the record after the object is created. Used by ObjectLevelReadQuery ResultSetAccessOptimization.
  • Constructor Details

    • DatabaseField

      public DatabaseField()
    • DatabaseField

      public DatabaseField(String qualifiedName)
    • DatabaseField

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

      public DatabaseField(String fieldName, String tableName)
    • DatabaseField

      public DatabaseField(String fieldName, DatabaseTable databaseTable)
    • 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

      public DatabaseField clone()
      The table is not cloned because it is treated as an automatic value.
      Overrides:
      clone in class Object
    • convertClassNamesToClasses

      public void convertClassNamesToClasses(ClassLoader classLoader)
    • equals

      public boolean equals(Object object)
      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.
      Overrides:
      equals in class Object
    • equals

      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.
    • getColumnDefinition

      public String 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

      public String getName()
      Return the unqualified name of the field.
      Specified by:
      getName in interface CoreField
    • getNameDelimited

      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.
    • getPrecision

      public int getPrecision()
      Returns the precision for a decimal column when generating DDL.
    • getQualifiedName

      public String getQualifiedName()
    • getQualifiedNameDelimited

      public String getQualifiedNameDelimited(DatasourcePlatform platform)
      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

      public DatabaseTable getTable()
    • getTableName

      public String getTableName()
    • setTableName

      public void setTableName(String tableName)
    • getType

      public Class<?> getType()
      Specified by:
      getType in interface CoreField
    • getTypeName

      public String getTypeName()
    • setTypeName

      public void setTypeName(String typeName)
    • 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.
      Overrides:
      hashCode in class Object
    • 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

      public void resetQualifiedName(String qualifiedName)
      Reset the field's name and table from the qualified name.
    • setColumnDefinition

      public void setColumnDefinition(String columnDefinition)
      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

      public void setName(String name)
      Set the unqualified name of the field.
      Specified by:
      setName in interface CoreField
    • setName

      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
    • setName

      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
    • 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

      public void setTable(DatabaseTable table)
      Set the table for the field.
    • setType

      public void setType(Class<?> type)
      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.
      Specified by:
      setType in interface CoreField
    • 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

      public String toString()
      Overrides:
      toString in class Object
    • 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

      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.
    • isCreatable

      public boolean isCreatable()
    • setCreatable

      public void setCreatable(boolean isCreatable)
    • getNameForComparisons

      public String getNameForComparisons()
      INTERNAL: gets the string used for comparisons and in determining the hashcode.