Class ColumnImpl
java.lang.Object
org.datanucleus.store.rdbms.table.ColumnImpl
- All Implemented Interfaces:
Column
,org.datanucleus.store.schema.table.Column
Implementation of a Column in an RDBMS datastore.
Contains the full definition of the column, its type, size, whether it is identity, nullable, part of the PK etc.
The SQL column definition is generated here.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
CHECK constraints to apply to this column in its SQL specification (optional).protected ColumnMapping
Mapping for this column.protected org.datanucleus.metadata.ColumnMetaData
ColumnMetaData for this column.private static final byte
protected Object
Default value accepted by the datastore for this column, from DatabaseMetaData.protected byte
Operational flags, for nullability, PK, autoinc, etc.protected DatastoreIdentifier
Identifier for the column in the datastore.private static final byte
private static final byte
private static final byte
protected final String
Java type that this column is storing.protected final Table
Table containing this column in the datastore.protected SQLTypeInfo
SQL Type info for the JDBC type being stored in this columnprotected String
Manual override of the type name for this column (optional).private static final byte
protected String[]
Function wrapping the column (for example, SQRT(COLUMN)).Fields inherited from interface org.datanucleus.store.rdbms.table.Column
WRAPPER_FUNCTION_INSERT, WRAPPER_FUNCTION_SELECT, WRAPPER_FUNCTION_UPDATE
-
Constructor Summary
ConstructorsConstructorDescriptionColumnImpl
(Table table, String javaType, DatastoreIdentifier identifier, org.datanucleus.metadata.ColumnMetaData colmd) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionapplySelectFunction
(String replacementValue) Wraps the column name with a FUNCTION.final void
Checks the column definition as a decimal.final void
Checks the column definition as an integer.final void
Checks the column definition as a primitive.final void
Checks the column definition as a string.void
copyConfigurationTo
(Column colIn) Copy the configuration of this field to another fieldboolean
Accessor for CHECK constraints for this column.Accessor for the column mapping that this column relates to.final org.datanucleus.metadata.ColumnMetaData
org.datanucleus.store.schema.naming.ColumnType
private String
Convenience method to return the "DEFAULT" part of the column definition.Accessor for the identifier for this object.Accessor for the JavaTypeMapping for the field/property that owns this column.org.datanucleus.metadata.JdbcType
org.datanucleus.store.schema.table.MemberColumnMapping
org.datanucleus.metadata.AbstractMemberMetaData
Accessor for the MetaData of the field/property that this is the column for.getName()
int
Accessor for the SQL definition of this column.private int
Accessor for the precision of data in the column.Accessor for the type of data stored in this field.Accessor for the StoreManager for this column.getTable()
Accessor for the table for this columnfinal SQLTypeInfo
Accessor for the type info for this column.getWrapperFunction
(int wrapperMode) Gets the wrapper for parameters.int
hashCode()
void
Initialize the default column value and auto incrementfinal boolean
boolean
Accessor for the whether this column is an identity column.final boolean
final boolean
final boolean
isUnique()
boolean
Convenience method to check if the length is required to be unlimited (BLOB/CLOB).final Column
setCheckConstraints
(String constraints) Mutator for the CHECK constraints of the column.void
setColumnMapping
(ColumnMapping mapping) Method to associate this column with its mapping.setColumnMetaData
(org.datanucleus.metadata.ColumnMetaData colmd) final Column
setDefaultable
(Object defaultValue) void
setIdentifier
(DatastoreIdentifier identifier) Mutator for the identifier of the column.setIdentity
(boolean identity) Mutator for whether we set this column as an identity column.setJdbcType
(org.datanucleus.metadata.JdbcType jdbcType) final Column
setNullable
(boolean flag) setPosition
(int pos) final Column
final Column
setTypeInfo
(SQLTypeInfo typeInfo) Mutator for the type information of the column.setTypeName
(String type) final Column
setUnique
(boolean flag) void
setWrapperFunction
(String wrapperFunction, int wrapperMode) Sets a function to wrap the column.toString()
void
Method to validate the contents of the column.
-
Field Details
-
PK
private static final byte PK- See Also:
-
NULLABLE
private static final byte NULLABLE- See Also:
-
UNIQUE
private static final byte UNIQUE- See Also:
-
DEFAULTABLE
private static final byte DEFAULTABLE- See Also:
-
IDENTITY
private static final byte IDENTITY- See Also:
-
identifier
Identifier for the column in the datastore. -
columnMetaData
protected org.datanucleus.metadata.ColumnMetaData columnMetaDataColumnMetaData for this column. -
table
Table containing this column in the datastore. -
columnMapping
Mapping for this column. -
storedJavaType
Java type that this column is storing. (can we just get this from the mapping above ?) -
typeName
Manual override of the type name for this column (optional). -
typeInfo
SQL Type info for the JDBC type being stored in this column -
checkConstraints
CHECK constraints to apply to this column in its SQL specification (optional). -
flags
protected byte flagsOperational flags, for nullability, PK, autoinc, etc. -
defaultValue
Default value accepted by the datastore for this column, from DatabaseMetaData. -
wrapperFunction
Function wrapping the column (for example, SQRT(COLUMN)).
-
-
Constructor Details
-
ColumnImpl
public ColumnImpl(Table table, String javaType, DatastoreIdentifier identifier, org.datanucleus.metadata.ColumnMetaData colmd) Constructor.- Parameters:
table
- The table in the datastore that this column belongs to.javaType
- The type of data being stored in this columnidentifier
- The identifier of the column (in the datastore).colmd
- The ColumnMetaData for this column
-
-
Method Details
-
getName
- Specified by:
getName
in interfaceorg.datanucleus.store.schema.table.Column
-
getMemberColumnMapping
public org.datanucleus.store.schema.table.MemberColumnMapping getMemberColumnMapping()- Specified by:
getMemberColumnMapping
in interfaceorg.datanucleus.store.schema.table.Column
-
getColumnType
public org.datanucleus.store.schema.naming.ColumnType getColumnType()- Specified by:
getColumnType
in interfaceorg.datanucleus.store.schema.table.Column
-
setJdbcType
- Specified by:
setJdbcType
in interfaceorg.datanucleus.store.schema.table.Column
-
getJdbcType
public org.datanucleus.metadata.JdbcType getJdbcType()- Specified by:
getJdbcType
in interfaceorg.datanucleus.store.schema.table.Column
-
setTypeName
- Specified by:
setTypeName
in interfaceorg.datanucleus.store.schema.table.Column
-
getTypeName
- Specified by:
getTypeName
in interfaceorg.datanucleus.store.schema.table.Column
-
setPosition
- Specified by:
setPosition
in interfaceorg.datanucleus.store.schema.table.Column
-
getPosition
public int getPosition()- Specified by:
getPosition
in interfaceorg.datanucleus.store.schema.table.Column
-
isUnlimitedLength
public boolean isUnlimitedLength()Description copied from interface:Column
Convenience method to check if the length is required to be unlimited (BLOB/CLOB).- Specified by:
isUnlimitedLength
in interfaceColumn
- Returns:
- Whether unlimited length required.
-
getIdentifier
Description copied from interface:Column
Accessor for the identifier for this object.- Specified by:
getIdentifier
in interfaceColumn
- Returns:
- The identifier.
-
setIdentifier
Description copied from interface:Column
Mutator for the identifier of the column.- Specified by:
setIdentifier
in interfaceColumn
- Parameters:
identifier
- The identifier
-
getTable
Description copied from interface:Column
Accessor for the table for this column -
getColumnMapping
Description copied from interface:Column
Accessor for the column mapping that this column relates to.- Specified by:
getColumnMapping
in interfaceColumn
- Returns:
- The column mapping
-
setColumnMapping
Description copied from interface:Column
Method to associate this column with its mapping.- Specified by:
setColumnMapping
in interfaceColumn
- Parameters:
mapping
- The mapping for this column
-
getJavaTypeMapping
Description copied from interface:Column
Accessor for the JavaTypeMapping for the field/property that owns this column.- Specified by:
getJavaTypeMapping
in interfaceColumn
- Returns:
- The JavaTypeMapping
-
getStoredJavaType
Description copied from interface:Column
Accessor for the type of data stored in this field.- Specified by:
getStoredJavaType
in interfaceColumn
- Returns:
- The type of data in the field.
-
setTypeInfo
Description copied from interface:Column
Mutator for the type information of the column.- Specified by:
setTypeInfo
in interfaceColumn
- Parameters:
typeInfo
- The type info- Returns:
- The column with the updated info
-
getTypeInfo
Description copied from interface:Column
Accessor for the type info for this column.- Specified by:
getTypeInfo
in interfaceColumn
- Returns:
- The type info
-
getStoreManager
Description copied from interface:Column
Accessor for the StoreManager for this column.- Specified by:
getStoreManager
in interfaceColumn
- Returns:
- The StoreManager.
-
getSQLPrecision
private int getSQLPrecision()Accessor for the precision of data in the column.- Returns:
- The precision of data in the column
-
getSQLDefinition
Description copied from interface:Column
Accessor for the SQL definition of this column.- Specified by:
getSQLDefinition
in interfaceColumn
- Returns:
- The SQL definition of the column
-
getDefaultDefinition
Convenience method to return the "DEFAULT" part of the column definition.- Returns:
- The default part of the column definition.
-
initializeColumnInfoFromDatastore
Description copied from interface:Column
Initialize the default column value and auto increment- Specified by:
initializeColumnInfoFromDatastore
in interfaceColumn
- Parameters:
ci
- The column information
-
validate
Description copied from interface:Column
Method to validate the contents of the column. This method can throw IncompatibleDataTypeException, WrongScaleException, WrongPrecisionException, IsNullableException if the data in the column is not compatible with the supplied ColumnInfo. -
setCheckConstraints
Description copied from interface:Column
Mutator for the CHECK constraints of the column.- Specified by:
setCheckConstraints
in interfaceColumn
- Parameters:
constraints
- The constraints- Returns:
- The column with the updated info
-
setPrimaryKey
- Specified by:
setPrimaryKey
in interfaceorg.datanucleus.store.schema.table.Column
-
setNullable
- Specified by:
setNullable
in interfaceorg.datanucleus.store.schema.table.Column
-
setDefaultable
- Specified by:
setDefaultable
in interfaceorg.datanucleus.store.schema.table.Column
-
setUnique
- Specified by:
setUnique
in interfaceorg.datanucleus.store.schema.table.Column
-
setIdentity
Description copied from interface:Column
Mutator for whether we set this column as an identity column. An "identity" column is typically treated differently in the datastore being given a value by the datastore itself. In RDBMS this would mean that the column is "AUTO_INCREMENT", "SERIAL" etc- Specified by:
setIdentity
in interfaceColumn
- Parameters:
identity
- True if column is identity- Returns:
- The Column
-
isPrimaryKey
public final boolean isPrimaryKey()- Specified by:
isPrimaryKey
in interfaceorg.datanucleus.store.schema.table.Column
-
isNullable
public final boolean isNullable()- Specified by:
isNullable
in interfaceorg.datanucleus.store.schema.table.Column
-
isDefaultable
public final boolean isDefaultable()- Specified by:
isDefaultable
in interfaceorg.datanucleus.store.schema.table.Column
-
isUnique
public final boolean isUnique()- Specified by:
isUnique
in interfaceorg.datanucleus.store.schema.table.Column
-
isIdentity
public boolean isIdentity()Description copied from interface:Column
Accessor for the whether this column is an identity column.- Specified by:
isIdentity
in interfaceColumn
- Returns:
- true if column is identity.
-
getDefaultValue
- Specified by:
getDefaultValue
in interfaceorg.datanucleus.store.schema.table.Column
-
getColumnMetaData
public final org.datanucleus.metadata.ColumnMetaData getColumnMetaData()- Specified by:
getColumnMetaData
in interfaceorg.datanucleus.store.schema.table.Column
-
getMemberMetaData
public org.datanucleus.metadata.AbstractMemberMetaData getMemberMetaData()Description copied from interface:Column
Accessor for the MetaData of the field/property that this is the column for.- Specified by:
getMemberMetaData
in interfaceColumn
- Returns:
- MetaData of the field/property (if representing a field/property of a class).
-
setColumnMetaData
- Specified by:
setColumnMetaData
in interfaceorg.datanucleus.store.schema.table.Column
-
getCheckConstraints
Description copied from interface:Column
Accessor for CHECK constraints for this column.- Specified by:
getCheckConstraints
in interfaceColumn
- Returns:
- Returns any CHECK constraints.
-
checkPrimitive
Description copied from interface:Column
Checks the column definition as a primitive.- Specified by:
checkPrimitive
in interfaceColumn
- Throws:
ColumnDefinitionException
- if an error occurs
-
checkInteger
Description copied from interface:Column
Checks the column definition as an integer.- Specified by:
checkInteger
in interfaceColumn
- Throws:
ColumnDefinitionException
- if an error occurs
-
checkDecimal
Description copied from interface:Column
Checks the column definition as a decimal.- Specified by:
checkDecimal
in interfaceColumn
- Throws:
ColumnDefinitionException
- if an error occurs
-
checkString
Description copied from interface:Column
Checks the column definition as a string.- Specified by:
checkString
in interfaceColumn
- Throws:
ColumnDefinitionException
- if an error occurs
-
copyConfigurationTo
Description copied from interface:Column
Copy the configuration of this field to another field- Specified by:
copyConfigurationTo
in interfaceColumn
- Parameters:
colIn
- the column to copy
-
applySelectFunction
Description copied from interface:Column
Wraps the column name with a FUNCTION.example: SQRT(?) generates: SQRT(columnName)
- Specified by:
applySelectFunction
in interfaceColumn
- Parameters:
replacementValue
- the replacement to ?. Probably it's a column name, that may be fully qualified name or not- Returns:
- a String with function taking as parameter the replacementValue
-
setWrapperFunction
Description copied from interface:Column
Sets a function to wrap the column. The wrapper function String must use "?" to be replaced later by the column name. For exampleSQRT(?) generates: SQRT(COLUMN)
- Specified by:
setWrapperFunction
in interfaceColumn
- Parameters:
wrapperFunction
- The wrapperFunction to set.wrapperMode
- whether select, insert or update
-
getWrapperFunction
Description copied from interface:Column
Gets the wrapper for parameters.- Specified by:
getWrapperFunction
in interfaceColumn
- Parameters:
wrapperMode
- whether select, insert or update- Returns:
- Returns the wrapperFunction.
-
equals
-
hashCode
public int hashCode() -
toString
-