Class SingleFieldMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
-
- Direct Known Subclasses:
AbstractContainerMapping
,BigDecimalMapping
,BigIntegerMapping
,BitSetMapping
,BooleanMapping
,ByteMapping
,CharacterMapping
,DatastoreIdMapping
,DiscriminatorMapping
,DoubleMapping
,EmbeddedMapping
,EnumMapping
,FileMapping
,FloatMapping
,IntegerMapping
,LongMapping
,NullMapping
,NumberMapping
,OrderIndexMapping
,SerialisedMapping
,ShortMapping
,SQLFunctionMapping
,StringMapping
,TemporalMapping
,TypeConverterMapping
,UUIDMapping
,VersionMapping
public abstract class SingleFieldMapping extends JavaTypeMapping
Simple mapping for a java field mapping to a single column.
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_CHECK_CONSTRAINT_VALUES
Metadata extension key that the column needs a CHECK constraint in the datastore on specific values.-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description SingleFieldMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getBoolean(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.byte
getByte(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.char
getChar(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.int
getDefaultLength(int index)
Accessor for the default length for this type in the datastore (if applicable).double
getDouble(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.float
getFloat(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.int
getInt(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.String
getJavaTypeForColumnMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular datastore field.long
getLong(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.Object
getObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.short
getShort(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.String
getString(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Obtains a value fromdatastoreResults
at position specified byexprIndex
.Object[]
getValidValues(int index)
Accessor for an array of valid values that this type can take.void
initialize(org.datanucleus.metadata.AbstractMemberMetaData fmd, Table table, org.datanucleus.ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.protected void
prepareColumnMapping()
Method to prepare a column mapping for use in the datastore.void
setBoolean(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, boolean value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setByte(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, byte value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setChar(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, char value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setDouble(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, double value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setFloat(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, float value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setInt(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, int value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setLong(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, long value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setShort(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, short value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.void
setString(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, String value)
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getColumnMapping, getColumnMappings, getColumnMetaDataForMember, getJavaType, getMemberMetaData, getNumberOfColumnMappings, getObject, getReferenceMapping, getRoleForMember, getStoreManager, getTable, getType, getValueForColumnMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setTable
-
-
-
-
Field Detail
-
EXTENSION_CHECK_CONSTRAINT_VALUES
public static final String EXTENSION_CHECK_CONSTRAINT_VALUES
Metadata extension key that the column needs a CHECK constraint in the datastore on specific values. Set it to the valid values.- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData fmd, Table table, org.datanucleus.ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.- Overrides:
initialize
in classJavaTypeMapping
- Parameters:
table
- The datastore container storing this mapping (if any)clr
- the ClassLoaderResolverfmd
- FieldMetaData for the field to be mapped (if any)
-
prepareColumnMapping
protected void prepareColumnMapping()
Method to prepare a column mapping for use in the datastore. This creates the column in the table.
-
getDefaultLength
public int getDefaultLength(int index)
Accessor for the default length for this type in the datastore (if applicable).- Parameters:
index
- requested column index.- Returns:
- Default length
-
getValidValues
public Object[] getValidValues(int index)
Accessor for an array of valid values that this type can take. This can be used at the datastore side for restricting the values to be inserted.- Parameters:
index
- requested column index.- Returns:
- The valid values
-
getJavaTypeForColumnMapping
public String getJavaTypeForColumnMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular datastore field. This java-type must have an entry in the datastore mappings.- Overrides:
getJavaTypeForColumnMapping
in classJavaTypeMapping
- Parameters:
index
- requested column index.- Returns:
- the name of java-type for the requested column.
-
setBoolean
public void setBoolean(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, boolean value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setBoolean
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getBoolean
public boolean getBoolean(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getBoolean
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setChar
public void setChar(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, char value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setChar
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getChar
public char getChar(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getChar
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setByte
public void setByte(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, byte value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setByte
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getByte
public byte getByte(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getByte
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setShort
public void setShort(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, short value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setShort
in classJavaTypeMapping
- Parameters:
ec
- execution contextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getShort
public short getShort(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getShort
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setInt
public void setInt(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, int value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setInt
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getInt
public int getInt(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getInt
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setLong
public void setLong(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, long value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setLong
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getLong
public long getLong(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getLong
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setFloat
public void setFloat(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, float value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setFloat
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getFloat
public float getFloat(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getFloat
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setDouble
public void setDouble(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, double value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setDouble
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getDouble
public double getDouble(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getDouble
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setString
public void setString(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, String value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setString
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getString
public String getString(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getString
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)
Description copied from class:JavaTypeMapping
Sets avalue
intodatastoreStatement
at position specified byexprIndex
.- Overrides:
setObject
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextps
- PreparedStatementexprIndex
- the position of the value in the statementvalue
- the value
-
getObject
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
Description copied from class:JavaTypeMapping
Obtains a value fromdatastoreResults
at position specified byexprIndex
.- Overrides:
getObject
in classJavaTypeMapping
- Parameters:
ec
- ExecutionContextresultSet
- ResultSetexprIndex
- the position of the value in the result- Returns:
- the value
-
-