Class ColumnImpl
- java.lang.Object
-
- org.datanucleus.store.rdbms.table.ColumnImpl
-
- All Implemented Interfaces:
Column,org.datanucleus.store.schema.table.Column
public class ColumnImpl extends Object implements 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
Fields Modifier and Type Field Description protected StringcheckConstraintsCHECK constraints to apply to this column in its SQL specification (optional).protected ColumnMappingcolumnMappingMapping for this column.protected org.datanucleus.metadata.ColumnMetaDatacolumnMetaDataColumnMetaData for this column.protected ObjectdefaultValueDefault value accepted by the datastore for this column, from DatabaseMetaData.protected byteflagsOperational flags, for nullability, PK, autoinc, etc.protected DatastoreIdentifieridentifierIdentifier for the column in the datastore.protected StringstoredJavaTypeJava type that this column is storing.protected TabletableTable containing this column in the datastore.protected SQLTypeInfotypeInfoSQL Type info for the JDBC type being stored in this columnprotected StringtypeNameManual override of the type name for this column (optional).protected String[]wrapperFunctionFunction 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
Constructors Constructor Description ColumnImpl(Table table, String javaType, DatastoreIdentifier identifier, org.datanucleus.metadata.ColumnMetaData colmd)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringapplySelectFunction(String replacementValue)Wraps the column name with a FUNCTION.voidcheckDecimal()Checks the column definition as a decimal.voidcheckInteger()Checks the column definition as an integer.voidcheckPrimitive()Checks the column definition as a primitive.voidcheckString()Checks the column definition as a string.voidcopyConfigurationTo(Column colIn)Copy the configuration of this field to another fieldbooleanequals(Object obj)StringgetCheckConstraints()Accessor for CHECK constraints for this column.ColumnMappinggetColumnMapping()Accessor for the column mapping that this column relates to.org.datanucleus.metadata.ColumnMetaDatagetColumnMetaData()org.datanucleus.store.schema.naming.ColumnTypegetColumnType()ObjectgetDefaultValue()DatastoreIdentifiergetIdentifier()Accessor for the identifier for this object.JavaTypeMappinggetJavaTypeMapping()Accessor for the JavaTypeMapping for the field/property that owns this column.org.datanucleus.metadata.JdbcTypegetJdbcType()org.datanucleus.store.schema.table.MemberColumnMappinggetMemberColumnMapping()org.datanucleus.metadata.AbstractMemberMetaDatagetMemberMetaData()Accessor for the MetaData of the field/property that this is the column for.StringgetName()intgetPosition()StringgetSQLDefinition()Accessor for the SQL definition of this column.StringgetStoredJavaType()Accessor for the type of data stored in this field.RDBMSStoreManagergetStoreManager()Accessor for the StoreManager for this column.TablegetTable()Accessor for the table for this columnSQLTypeInfogetTypeInfo()Accessor for the type info for this column.StringgetTypeName()StringgetWrapperFunction(int wrapperMode)Gets the wrapper for parameters.inthashCode()voidinitializeColumnInfoFromDatastore(RDBMSColumnInfo ci)Initialize the default column value and auto incrementbooleanisDefaultable()booleanisIdentity()Accessor for the whether this column is an identity column.booleanisNullable()booleanisPrimaryKey()booleanisUnique()booleanisUnlimitedLength()Convenience method to check if the length is required to be unlimited (BLOB/CLOB).ColumnsetCheckConstraints(String constraints)Mutator for the CHECK constraints of the column.voidsetColumnMapping(ColumnMapping mapping)Method to associate this column with its mapping.ColumnsetColumnMetaData(org.datanucleus.metadata.ColumnMetaData colmd)ColumnsetDefaultable(Object defaultValue)voidsetIdentifier(DatastoreIdentifier identifier)Mutator for the identifier of the column.ColumnsetIdentity(boolean identity)Mutator for whether we set this column as an identity column.ColumnsetJdbcType(org.datanucleus.metadata.JdbcType jdbcType)ColumnsetNullable(boolean flag)ColumnsetPosition(int pos)ColumnsetPrimaryKey()ColumnsetTypeInfo(SQLTypeInfo typeInfo)Mutator for the type information of the column.ColumnsetTypeName(String type)ColumnsetUnique(boolean flag)voidsetWrapperFunction(String wrapperFunction, int wrapperMode)Sets a function to wrap the column.StringtoString()voidvalidate(RDBMSColumnInfo ci)Method to validate the contents of the column.
-
-
-
Field Detail
-
identifier
protected DatastoreIdentifier identifier
Identifier for the column in the datastore.
-
columnMetaData
protected org.datanucleus.metadata.ColumnMetaData columnMetaData
ColumnMetaData for this column.
-
table
protected final Table table
Table containing this column in the datastore.
-
columnMapping
protected ColumnMapping columnMapping
Mapping for this column.
-
storedJavaType
protected final String storedJavaType
Java type that this column is storing. (can we just get this from the mapping above ?)
-
typeName
protected String typeName
Manual override of the type name for this column (optional).
-
typeInfo
protected SQLTypeInfo typeInfo
SQL Type info for the JDBC type being stored in this column
-
checkConstraints
protected String checkConstraints
CHECK constraints to apply to this column in its SQL specification (optional).
-
flags
protected byte flags
Operational flags, for nullability, PK, autoinc, etc.
-
defaultValue
protected Object defaultValue
Default value accepted by the datastore for this column, from DatabaseMetaData.
-
wrapperFunction
protected String[] wrapperFunction
Function wrapping the column (for example, SQRT(COLUMN)).
-
-
Constructor Detail
-
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 Detail
-
getName
public String getName()
- Specified by:
getNamein interfaceorg.datanucleus.store.schema.table.Column
-
getMemberColumnMapping
public org.datanucleus.store.schema.table.MemberColumnMapping getMemberColumnMapping()
- Specified by:
getMemberColumnMappingin interfaceorg.datanucleus.store.schema.table.Column
-
getColumnType
public org.datanucleus.store.schema.naming.ColumnType getColumnType()
- Specified by:
getColumnTypein interfaceorg.datanucleus.store.schema.table.Column
-
setJdbcType
public Column setJdbcType(org.datanucleus.metadata.JdbcType jdbcType)
- Specified by:
setJdbcTypein interfaceorg.datanucleus.store.schema.table.Column
-
getJdbcType
public org.datanucleus.metadata.JdbcType getJdbcType()
- Specified by:
getJdbcTypein interfaceorg.datanucleus.store.schema.table.Column
-
setTypeName
public Column setTypeName(String type)
- Specified by:
setTypeNamein interfaceorg.datanucleus.store.schema.table.Column
-
getTypeName
public String getTypeName()
- Specified by:
getTypeNamein interfaceorg.datanucleus.store.schema.table.Column
-
setPosition
public Column setPosition(int pos)
- Specified by:
setPositionin interfaceorg.datanucleus.store.schema.table.Column
-
getPosition
public int getPosition()
- Specified by:
getPositionin interfaceorg.datanucleus.store.schema.table.Column
-
isUnlimitedLength
public boolean isUnlimitedLength()
Description copied from interface:ColumnConvenience method to check if the length is required to be unlimited (BLOB/CLOB).- Specified by:
isUnlimitedLengthin interfaceColumn- Returns:
- Whether unlimited length required.
-
getIdentifier
public DatastoreIdentifier getIdentifier()
Description copied from interface:ColumnAccessor for the identifier for this object.- Specified by:
getIdentifierin interfaceColumn- Returns:
- The identifier.
-
setIdentifier
public void setIdentifier(DatastoreIdentifier identifier)
Description copied from interface:ColumnMutator for the identifier of the column.- Specified by:
setIdentifierin interfaceColumn- Parameters:
identifier- The identifier
-
getTable
public Table getTable()
Description copied from interface:ColumnAccessor for the table for this column
-
getColumnMapping
public ColumnMapping getColumnMapping()
Description copied from interface:ColumnAccessor for the column mapping that this column relates to.- Specified by:
getColumnMappingin interfaceColumn- Returns:
- The column mapping
-
setColumnMapping
public void setColumnMapping(ColumnMapping mapping)
Description copied from interface:ColumnMethod to associate this column with its mapping.- Specified by:
setColumnMappingin interfaceColumn- Parameters:
mapping- The mapping for this column
-
getJavaTypeMapping
public JavaTypeMapping getJavaTypeMapping()
Description copied from interface:ColumnAccessor for the JavaTypeMapping for the field/property that owns this column.- Specified by:
getJavaTypeMappingin interfaceColumn- Returns:
- The JavaTypeMapping
-
getStoredJavaType
public String getStoredJavaType()
Description copied from interface:ColumnAccessor for the type of data stored in this field.- Specified by:
getStoredJavaTypein interfaceColumn- Returns:
- The type of data in the field.
-
setTypeInfo
public final Column setTypeInfo(SQLTypeInfo typeInfo)
Description copied from interface:ColumnMutator for the type information of the column.- Specified by:
setTypeInfoin interfaceColumn- Parameters:
typeInfo- The type info- Returns:
- The column with the updated info
-
getTypeInfo
public final SQLTypeInfo getTypeInfo()
Description copied from interface:ColumnAccessor for the type info for this column.- Specified by:
getTypeInfoin interfaceColumn- Returns:
- The type info
-
getStoreManager
public RDBMSStoreManager getStoreManager()
Description copied from interface:ColumnAccessor for the StoreManager for this column.- Specified by:
getStoreManagerin interfaceColumn- Returns:
- The StoreManager.
-
getSQLDefinition
public String getSQLDefinition()
Description copied from interface:ColumnAccessor for the SQL definition of this column.- Specified by:
getSQLDefinitionin interfaceColumn- Returns:
- The SQL definition of the column
-
initializeColumnInfoFromDatastore
public void initializeColumnInfoFromDatastore(RDBMSColumnInfo ci)
Description copied from interface:ColumnInitialize the default column value and auto increment- Specified by:
initializeColumnInfoFromDatastorein interfaceColumn- Parameters:
ci- The column information
-
validate
public void validate(RDBMSColumnInfo ci)
Description copied from interface:ColumnMethod 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
public final Column setCheckConstraints(String constraints)
Description copied from interface:ColumnMutator for the CHECK constraints of the column.- Specified by:
setCheckConstraintsin interfaceColumn- Parameters:
constraints- The constraints- Returns:
- The column with the updated info
-
setPrimaryKey
public final Column setPrimaryKey()
- Specified by:
setPrimaryKeyin interfaceorg.datanucleus.store.schema.table.Column
-
setNullable
public final Column setNullable(boolean flag)
- Specified by:
setNullablein interfaceorg.datanucleus.store.schema.table.Column
-
setDefaultable
public final Column setDefaultable(Object defaultValue)
- Specified by:
setDefaultablein interfaceorg.datanucleus.store.schema.table.Column
-
setUnique
public final Column setUnique(boolean flag)
- Specified by:
setUniquein interfaceorg.datanucleus.store.schema.table.Column
-
setIdentity
public Column setIdentity(boolean identity)
Description copied from interface:ColumnMutator 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:
setIdentityin interfaceColumn- Parameters:
identity- True if column is identity- Returns:
- The Column
-
isPrimaryKey
public final boolean isPrimaryKey()
- Specified by:
isPrimaryKeyin interfaceorg.datanucleus.store.schema.table.Column
-
isNullable
public final boolean isNullable()
- Specified by:
isNullablein interfaceorg.datanucleus.store.schema.table.Column
-
isDefaultable
public final boolean isDefaultable()
- Specified by:
isDefaultablein interfaceorg.datanucleus.store.schema.table.Column
-
isUnique
public final boolean isUnique()
- Specified by:
isUniquein interfaceorg.datanucleus.store.schema.table.Column
-
isIdentity
public boolean isIdentity()
Description copied from interface:ColumnAccessor for the whether this column is an identity column.- Specified by:
isIdentityin interfaceColumn- Returns:
- true if column is identity.
-
getDefaultValue
public Object getDefaultValue()
- Specified by:
getDefaultValuein interfaceorg.datanucleus.store.schema.table.Column
-
getColumnMetaData
public final org.datanucleus.metadata.ColumnMetaData getColumnMetaData()
- Specified by:
getColumnMetaDatain interfaceorg.datanucleus.store.schema.table.Column
-
getMemberMetaData
public org.datanucleus.metadata.AbstractMemberMetaData getMemberMetaData()
Description copied from interface:ColumnAccessor for the MetaData of the field/property that this is the column for.- Specified by:
getMemberMetaDatain interfaceColumn- Returns:
- MetaData of the field/property (if representing a field/property of a class).
-
setColumnMetaData
public Column setColumnMetaData(org.datanucleus.metadata.ColumnMetaData colmd)
- Specified by:
setColumnMetaDatain interfaceorg.datanucleus.store.schema.table.Column
-
getCheckConstraints
public String getCheckConstraints()
Description copied from interface:ColumnAccessor for CHECK constraints for this column.- Specified by:
getCheckConstraintsin interfaceColumn- Returns:
- Returns any CHECK constraints.
-
checkPrimitive
public final void checkPrimitive() throws ColumnDefinitionExceptionDescription copied from interface:ColumnChecks the column definition as a primitive.- Specified by:
checkPrimitivein interfaceColumn- Throws:
ColumnDefinitionException- if an error occurs
-
checkInteger
public final void checkInteger() throws ColumnDefinitionExceptionDescription copied from interface:ColumnChecks the column definition as an integer.- Specified by:
checkIntegerin interfaceColumn- Throws:
ColumnDefinitionException- if an error occurs
-
checkDecimal
public final void checkDecimal() throws ColumnDefinitionExceptionDescription copied from interface:ColumnChecks the column definition as a decimal.- Specified by:
checkDecimalin interfaceColumn- Throws:
ColumnDefinitionException- if an error occurs
-
checkString
public final void checkString() throws ColumnDefinitionExceptionDescription copied from interface:ColumnChecks the column definition as a string.- Specified by:
checkStringin interfaceColumn- Throws:
ColumnDefinitionException- if an error occurs
-
copyConfigurationTo
public void copyConfigurationTo(Column colIn)
Description copied from interface:ColumnCopy the configuration of this field to another field- Specified by:
copyConfigurationToin interfaceColumn- Parameters:
colIn- the column to copy
-
applySelectFunction
public String applySelectFunction(String replacementValue)
Description copied from interface:ColumnWraps the column name with a FUNCTION.example: SQRT(?) generates: SQRT(columnName)
- Specified by:
applySelectFunctionin 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
public void setWrapperFunction(String wrapperFunction, int wrapperMode)
Description copied from interface:ColumnSets 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:
setWrapperFunctionin interfaceColumn- Parameters:
wrapperFunction- The wrapperFunction to set.wrapperMode- whether select, insert or update
-
getWrapperFunction
public String getWrapperFunction(int wrapperMode)
Description copied from interface:ColumnGets the wrapper for parameters.- Specified by:
getWrapperFunctionin interfaceColumn- Parameters:
wrapperMode- whether select, insert or update- Returns:
- Returns the wrapperFunction.
-
-