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 Column
The Column being persisted to.protected final JavaTypeMapping
Mapping of the Java type.protected final RDBMSStoreManager
Store Manager to use for mapping. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractColumnMapping
(RDBMSStoreManager storeMgr, JavaTypeMapping mapping) Create a new Mapping with the given DatabaseAdapter for the given type. -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected String
failureMessage
(String method) Utility to output any error message.protected String
failureMessage
(String method, int position, Exception e) Utility to output any error message.protected String
failureMessage
(String method, Object value, Exception e) Utility to output any error message.boolean
getBoolean
(ResultSet resultSet, int exprIndex) Obtains a value fromresultSet
at position specified byexprIndex
.byte
Obtains a value fromresultSet
at position specified byexprIndex
.char
Obtains a value fromresultSet
at position specified byexprIndex
.Accessor for the columnprotected DatastoreAdapter
Convenience to access the datastore adapter.double
Obtains a value fromresultSet
at position specified byexprIndex
.float
Obtains a value fromresultSet
at position specified byexprIndex
.Accessor for the string to put in any retrieval datastore statement for this field.int
Obtains a value fromresultSet
at position specified byexprIndex
.Accessor for the java type mappingabstract int
Method to return the java.sql.Types type that this relates to.long
Obtains a value fromresultSet
at position specified byexprIndex
.Obtains a value fromresultSet
at position specified byexprIndex
.short
Obtains a value fromresultSet
at position specified byexprIndex
.Obtains a value fromresultSet
at 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.int
hashCode()
boolean
Whether this mapping is included in the fetch statement.protected void
Sets the TypeInfo for the columns of the Mapping.boolean
Accessor for whether this mapping requires values inserting on an INSERT.boolean
Accessor for whether the mapping is bit-based.boolean
Accessor for whether the mapping is boolean-based.boolean
Accessor for whether the mapping is decimal-based.boolean
Accessor for whether the mapping is integer-based.boolean
Accessor for whether the mapping is nullable.boolean
Accessor for whether the mapping is string-based.void
setBoolean
(PreparedStatement ps, int exprIndex, boolean value) Sets avalue
intops
at position specified byparamIndex
.void
setByte
(PreparedStatement ps, int exprIndex, byte value) Sets avalue
intops
at position specified byparamIndex
.void
setChar
(PreparedStatement ps, int exprIndex, char value) Sets avalue
intops
at position specified byparamIndex
.void
setDouble
(PreparedStatement ps, int exprIndex, double value) Sets avalue
intops
at position specified byparamIndex
.void
setFloat
(PreparedStatement ps, int exprIndex, float value) Sets avalue
intops
at position specified byparamIndex
.void
setInt
(PreparedStatement ps, int exprIndex, int value) Sets avalue
intops
at position specified byparamIndex
.void
setLong
(PreparedStatement ps, int exprIndex, long value) Sets avalue
intops
at position specified byparamIndex
.void
setObject
(PreparedStatement ps, int exprIndex, Object value) Sets avalue
intops
at position specified byparamIndex
.void
setShort
(PreparedStatement ps, int exprIndex, short value) Sets avalue
intops
at position specified byparamIndex
.void
setString
(PreparedStatement ps, int exprIndex, String value) Sets avalue
intops
at 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:
getJavaTypeMapping
in 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:
isNullable
in 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:
insertValuesOnInsert
in 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:
getInsertionInputParameter
in 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:
getUpdateInputParameter
in interfaceColumnMapping
- Returns:
- The input parameter.
-
getColumn
Accessor for the column- Specified by:
getColumn
in interfaceColumnMapping
- Returns:
- The column
-
equals
-
hashCode
public int hashCode() -
useDefaultWhenNull
protected boolean useDefaultWhenNull() -
failureMessage
Utility to output any error message.- Parameters:
method
- The method that failed.position
- The position of the columne
- The exception- Returns:
- The localised failure message
-
failureMessage
Utility to output any error message.- Parameters:
method
- The method that failed.value
- Value at the positione
- The exception- Returns:
- The localised failure message
-
setBoolean
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setBoolean
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getBoolean
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getBoolean
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setChar
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setChar
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getChar
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getChar
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setByte
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setByte
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getByte
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getByte
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setShort
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setShort
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getShort
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getShort
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setInt
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setInt
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getInt
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getInt
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setLong
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setLong
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getLong
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getLong
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setFloat
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setFloat
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getFloat
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getFloat
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setDouble
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setDouble
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getDouble
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getDouble
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setString
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setString
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getString
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getString
in interfaceColumnMapping
- Parameters:
resultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setObject
Description copied from interface:ColumnMapping
Sets avalue
intops
at position specified byparamIndex
.- Specified by:
setObject
in interfaceColumnMapping
- Parameters:
ps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getObject
Description copied from interface:ColumnMapping
Obtains a value fromresultSet
at position specified byexprIndex
.- Specified by:
getObject
in 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:
isDecimalBased
in interfaceColumnMapping
- Returns:
- Whether the mapping is decimal based
-
isIntegerBased
public boolean isIntegerBased()Accessor for whether the mapping is integer-based.- Specified by:
isIntegerBased
in interfaceColumnMapping
- Returns:
- Whether the mapping is integer based
-
isStringBased
public boolean isStringBased()Accessor for whether the mapping is string-based.- Specified by:
isStringBased
in interfaceColumnMapping
- Returns:
- Whether the mapping is string based
-
isBitBased
public boolean isBitBased()Accessor for whether the mapping is bit-based.- Specified by:
isBitBased
in interfaceColumnMapping
- Returns:
- Whether the mapping is bit based
-
isBooleanBased
public boolean isBooleanBased()Accessor for whether the mapping is boolean-based.- Specified by:
isBooleanBased
in interfaceColumnMapping
- Returns:
- Whether the mapping is boolean based
-
failureMessage
Utility to output any error message.- Parameters:
method
- The method that failed.- Returns:
- The localised failure message
-