Class TypeConverterMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
-
- org.datanucleus.store.rdbms.mapping.java.TypeConverterMapping
-
public class TypeConverterMapping extends SingleFieldMapping
Mapping where the member has its value converted to/from some storable datastore type using a TypeConverter.
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
EXTENSION_CHECK_CONSTRAINT_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 TypeConverterMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetBoolean(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.bytegetByte(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.chargetChar(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.intgetDefaultLength(int index)Accessor for the default length for this type in the datastore (if applicable).doublegetDouble(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.floatgetFloat(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.intgetInt(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.ClassgetJavaType()Accessor for the java type being mapped.StringgetJavaTypeForColumnMapping(int index)Accessor for the name of the java-type actually used when mapping the particular column.longgetLong(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.protected ObjectgetMemberValueFromDatastore(ResultSet resultSet, int[] exprIndex)Method that retrieves the datastore value and converts it back to the member value.ObjectgetObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.shortgetShort(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.StringgetString(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.org.datanucleus.store.types.converters.TypeConvertergetTypeConverter()voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.types.converters.TypeConverter conv)voidinitialize(RDBMSStoreManager storeMgr, String type)Initialise this JavaTypeMapping with the given StoreManager for the given type.voidsetBoolean(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, boolean value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetByte(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, byte value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetChar(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, char value)Sets avalueintodatastoreStatementat position specified byexprIndex.protected voidsetDatastoreFromMemberValue(PreparedStatement ps, int[] exprIndex, Object memberValue)Method that takes the member value and sets the datastore value in the PreparedStatement at the specified position.voidsetDouble(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, double value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetFloat(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, float value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetInt(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, int value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetLong(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, long value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetShort(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, short value)Sets avalueintodatastoreStatementat position specified byexprIndex.voidsetString(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, String value)Sets avalueintodatastoreStatementat position specified byexprIndex.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMapping
getValidValues, prepareColumnMapping
-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getColumnMapping, getColumnMappings, getColumnMetaDataForMember, getMemberMetaData, getNumberOfColumnMappings, getObject, getReferenceMapping, getRoleForMember, getStoreManager, getTable, getType, getValueForColumnMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, insertPostProcessing, isNullable, isSerialised, representableAsStringLiteralInStatement, requiresInsertPostProcessing, requiresUpdatePostProcessing, setAbsFieldNumber, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setTable, updatePostProcessing
-
-
-
-
Method Detail
-
initialize
public void initialize(RDBMSStoreManager storeMgr, String type)
Description copied from class:JavaTypeMappingInitialise this JavaTypeMapping with the given StoreManager for the given type. Used when the mapping is for a parameter in a query. This will not set the "mmd" and "datastoreContainer" parameters. If these are required for usage of the mapping then you should call "setFieldInformation(AbstractMemberMetaData, DatastoreContainerObject)" below Subclasses should override this method to perform any datastore initialization operations.- Overrides:
initializein classJavaTypeMapping- Parameters:
storeMgr- The Datastore Adapter that this Mapping should use.type- The Class that this mapping maps to the database.
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Description copied from class:SingleFieldMappingInitialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.- Overrides:
initializein classSingleFieldMapping- Parameters:
mmd- FieldMetaData for the field to be mapped (if any)table- The datastore container storing this mapping (if any)clr- the ClassLoaderResolver
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.types.converters.TypeConverter conv)
-
getTypeConverter
public org.datanucleus.store.types.converters.TypeConverter getTypeConverter()
-
getDefaultLength
public int getDefaultLength(int index)
Description copied from class:SingleFieldMappingAccessor for the default length for this type in the datastore (if applicable).- Overrides:
getDefaultLengthin classSingleFieldMapping- Parameters:
index- requested column index.- Returns:
- Default length
-
getJavaTypeForColumnMapping
public String getJavaTypeForColumnMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular column. This java-type must have an entry in the column mappings.- Overrides:
getJavaTypeForColumnMappingin classSingleFieldMapping- Parameters:
index- requested column index.- Returns:
- the name of java-type for the requested column.
-
getJavaType
public Class getJavaType()
Description copied from class:JavaTypeMappingAccessor for the java type being mapped. This is the java type that the mapping represents. Some examples :- if the field is of type "MyClass" then the mapping will be OIDMapping (or subclass) the javaType will be OID, and the type will be MyClass.
- if the field is of type "int" then the mapping will be IntegerMapping, the javaType will be Integer, and the type will be int.
- Specified by:
getJavaTypein classJavaTypeMapping- Returns:
- The java type
-
setDatastoreFromMemberValue
protected void setDatastoreFromMemberValue(PreparedStatement ps, int[] exprIndex, Object memberValue)
Method that takes the member value and sets the datastore value in the PreparedStatement at the specified position.- Parameters:
ps- The PreparedStatementexprIndex- The position in the statementmemberValue- The member value for this field
-
getMemberValueFromDatastore
protected Object getMemberValueFromDatastore(ResultSet resultSet, int[] exprIndex)
Method that retrieves the datastore value and converts it back to the member value.- Parameters:
resultSet- The result setexprIndex- The position in the result set- Returns:
- The member value
-
setBoolean
public void setBoolean(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, boolean value)Description copied from class:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setBooleanin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getBooleanin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setBytein classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getBytein classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setCharin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getCharin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setDoublein classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getDoublein classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setFloatin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getFloatin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setIntin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getIntin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setLongin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getLongin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setShortin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getShortin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setStringin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getStringin classSingleFieldMapping- 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:JavaTypeMappingSets avalueintodatastoreStatementat position specified byexprIndex.- Overrides:
setObjectin classSingleFieldMapping- 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getObjectin classSingleFieldMapping- Parameters:
ec- ExecutionContextresultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
-