Class AbstractColumnMapping
java.lang.Object
org.datanucleus.store.rdbms.mapping.column.AbstractColumnMapping
- All Implemented Interfaces:
ColumnMapping
- Direct Known Subclasses:
AbstractLargeBinaryColumnMapping, ArrayColumnMapping, BigIntColumnMapping, BinaryStreamColumnMapping, BooleanColumnMapping, CharColumnMapping, DateColumnMapping, DecimalColumnMapping, DoubleColumnMapping, IntegerColumnMapping, LongVarcharColumnMapping, NumericColumnMapping, OtherColumnMapping, RealColumnMapping, SmallIntColumnMapping, TimeColumnMapping, TimestampColumnMapping, TinyIntColumnMapping
Implementation of the mapping of a column.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ColumnThe Column being persisted to.protected final JavaTypeMappingMapping of the Java type.protected final RDBMSStoreManagerStore Manager to use for mapping. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractColumnMapping(RDBMSStoreManager storeMgr, JavaTypeMapping mapping) Create a new Mapping with the given DatabaseAdapter for the given type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected StringfailureMessage(String method) Utility to output any error message.protected StringfailureMessage(String method, int position, Exception e) Utility to output any error message.protected StringfailureMessage(String method, Object value, Exception e) Utility to output any error message.booleangetBoolean(ResultSet resultSet, int exprIndex) Obtains a value fromresultSetat position specified byexprIndex.byteObtains a value fromresultSetat position specified byexprIndex.charObtains a value fromresultSetat position specified byexprIndex.Accessor for the columnprotected DatastoreAdapterConvenience to access the datastore adapter.doubleObtains a value fromresultSetat position specified byexprIndex.floatObtains a value fromresultSetat position specified byexprIndex.Accessor for the string to put in any retrieval datastore statement for this field.intObtains a value fromresultSetat position specified byexprIndex.Accessor for the java type mappingabstract intMethod to return the java.sql.Types type that this relates to.longObtains a value fromresultSetat position specified byexprIndex.Obtains a value fromresultSetat position specified byexprIndex.shortObtains a value fromresultSetat position specified byexprIndex.Obtains a value fromresultSetat position specified byexprIndex.Accessor for the (SQL) type info for this datastore type.Accessor for the string to put in any update datastore statements for this field.inthashCode()booleanWhether this mapping is included in the fetch statement.protected voidSets the TypeInfo for the columns of the Mapping.booleanAccessor for whether this mapping requires values inserting on an INSERT.booleanAccessor for whether the mapping is bit-based.booleanAccessor for whether the mapping is boolean-based.booleanAccessor for whether the mapping is decimal-based.booleanAccessor for whether the mapping is integer-based.booleanAccessor for whether the mapping is nullable.booleanAccessor for whether the mapping is string-based.voidsetBoolean(PreparedStatement ps, int exprIndex, boolean value) Sets avalueintopsat position specified byparamIndex.voidsetByte(PreparedStatement ps, int exprIndex, byte value) Sets avalueintopsat position specified byparamIndex.voidsetChar(PreparedStatement ps, int exprIndex, char value) Sets avalueintopsat position specified byparamIndex.voidsetDouble(PreparedStatement ps, int exprIndex, double value) Sets avalueintopsat position specified byparamIndex.voidsetFloat(PreparedStatement ps, int exprIndex, float value) Sets avalueintopsat position specified byparamIndex.voidsetInt(PreparedStatement ps, int exprIndex, int value) Sets avalueintopsat position specified byparamIndex.voidsetLong(PreparedStatement ps, int exprIndex, long value) Sets avalueintopsat position specified byparamIndex.voidsetObject(PreparedStatement ps, int exprIndex, Object value) Sets avalueintopsat position specified byparamIndex.voidsetShort(PreparedStatement ps, int exprIndex, short value) Sets avalueintopsat position specified byparamIndex.voidsetString(PreparedStatement ps, int exprIndex, String value) Sets avalueintopsat position specified byparamIndex.protected boolean
-
Field Details
-
mapping
Mapping of the Java type. -
storeMgr
Store Manager to use for mapping. -
column
The Column being persisted to.
-
-
Constructor Details
-
AbstractColumnMapping
Create a new Mapping with the given DatabaseAdapter for the given type.- Parameters:
storeMgr- The Store Manager that this Mapping should use.mapping- Mapping for the underlying java type. This can be null on an "unmapped column".
-
-
Method Details
-
getJavaTypeMapping
Accessor for the java type mapping- Specified by:
getJavaTypeMappingin interfaceColumnMapping- Returns:
- The java type mapping used
-
getDatastoreAdapter
Convenience to access the datastore adapter.- Returns:
- The adapter in use
-
initTypeInfo
protected void initTypeInfo()Sets the TypeInfo for the columns of the Mapping. Mappings using two or more columns using different TypeInfo(s) should overwrite this method to appropriate set the TypeInfo (SQL type) for all the columns -
getJDBCType
public abstract int getJDBCType()Method to return the java.sql.Types type that this relates to.- Returns:
- The JDBC "type"
-
getTypeInfo
Accessor for the (SQL) type info for this datastore type. Finds the SQLTypeInfo using the JDBC Type for this mapping. Override if you want a different method.- Returns:
- The type info
-
isNullable
public boolean isNullable()Accessor for whether the mapping is nullable.- Specified by:
isNullablein interfaceColumnMapping- Returns:
- Whether it is nullable
-
includeInFetchStatement
public boolean includeInFetchStatement()Whether this mapping is included in the fetch statement.- Returns:
- Whether to include in fetch statement
-
insertValuesOnInsert
public boolean insertValuesOnInsert()Accessor for whether this mapping requires values inserting on an INSERT.- Specified by:
insertValuesOnInsertin interfaceColumnMapping- Returns:
- Whether values are to be inserted into this mapping on an INSERT
-
getInsertionInputParameter
Accessor for the string to put in any retrieval datastore statement for this field. In RDBMS, this is typically a ? to be used in JDBC statements.- Specified by:
getInsertionInputParameterin interfaceColumnMapping- Returns:
- The input parameter
-
getUpdateInputParameter
Accessor for the string to put in any update datastore statements for this field. In RDBMS, this is typically a ? to be used in JDBC statements.- Specified by:
getUpdateInputParameterin interfaceColumnMapping- Returns:
- The input parameter.
-
getColumn
Accessor for the column- Specified by:
getColumnin interfaceColumnMapping- Returns:
- The column
-
equals
-
hashCode
-
useDefaultWhenNull
protected boolean useDefaultWhenNull() -
failureMessage
-
failureMessage
-
setBoolean
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setBooleanin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getBoolean
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getBooleanin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setChar
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setCharin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getChar
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getCharin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setByte
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setBytein interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getByte
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getBytein interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setShort
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setShortin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getShort
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getShortin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setInt
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setIntin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getInt
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getIntin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setLong
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setLongin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getLong
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getLongin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setFloat
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setFloatin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getFloat
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getFloatin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setDouble
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setDoublein interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getDouble
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getDoublein interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setString
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setStringin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getString
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getStringin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
setObject
Description copied from interface:ColumnMappingSets avalueintopsat position specified byparamIndex.- Specified by:
setObjectin interfaceColumnMapping- Parameters:
ps- PreparedStatementexprIndex- the position of the value in the statementvalue- the value
-
getObject
Description copied from interface:ColumnMappingObtains a value fromresultSetat position specified byexprIndex.- Specified by:
getObjectin interfaceColumnMapping- Parameters:
resultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
isDecimalBased
public boolean isDecimalBased()Accessor for whether the mapping is decimal-based.- Specified by:
isDecimalBasedin interfaceColumnMapping- Returns:
- Whether the mapping is decimal based
-
isIntegerBased
public boolean isIntegerBased()Accessor for whether the mapping is integer-based.- Specified by:
isIntegerBasedin interfaceColumnMapping- Returns:
- Whether the mapping is integer based
-
isStringBased
public boolean isStringBased()Accessor for whether the mapping is string-based.- Specified by:
isStringBasedin interfaceColumnMapping- Returns:
- Whether the mapping is string based
-
isBitBased
public boolean isBitBased()Accessor for whether the mapping is bit-based.- Specified by:
isBitBasedin interfaceColumnMapping- Returns:
- Whether the mapping is bit based
-
isBooleanBased
public boolean isBooleanBased()Accessor for whether the mapping is boolean-based.- Specified by:
isBooleanBasedin interfaceColumnMapping- Returns:
- Whether the mapping is boolean based
-
failureMessage
-