Class GregorianCalendarMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SingleFieldMultiMapping
-
- org.datanucleus.store.rdbms.mapping.java.GregorianCalendarMapping
-
public class GregorianCalendarMapping extends SingleFieldMultiMapping
Maps the class fields of a GregorianCalendar to column(s). We default to a single column (timestamp), but allow the option of persisting to 2 columns (timestamp millisecs and timezone). JPOX traditionally supported persistence to 2 columns. TODO Remove this and use converters for the different options : (Long, String), (Timestamp).
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description GregorianCalendarMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddColumns()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.ObjectgetObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)Obtains a value fromdatastoreResultsat position specified byexprIndex.ObjectgetValueForColumnMapping(org.datanucleus.NucleusContext nucleusCtx, int index, Object value)Method to return the value to be stored in the specified datastore index given the overall value for this java type.voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData fmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping for the supplied table and field/property metadata.voidinitialize(RDBMSStoreManager storeMgr, String type)Initialise this JavaTypeMapping with the given StoreManager for the given type.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value)Sets avalueintodatastoreStatementat position specified byexprIndex.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.SingleFieldMultiMapping
addColumns, hasSimpleDatastoreRepresentation
-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getBoolean, getByte, getChar, getColumnMapping, getColumnMappings, getColumnMetaDataForMember, getDouble, getFloat, getInt, getLong, getMemberMetaData, getNumberOfColumnMappings, getObject, getReferenceMapping, getRoleForMember, getShort, getStoreManager, getString, getTable, getType, hashCode, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, isNullable, isSerialised, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setShort, setString, setTable
-
-
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData fmd, Table table, org.datanucleus.ClassLoaderResolver clr)Description copied from class:JavaTypeMappingInitialize this JavaTypeMapping for the supplied table and field/property metadata. Subclasses should override this method to perform any datastore initialization operations. Assumes the "roleForMember" is already set- Overrides:
initializein classJavaTypeMapping- Parameters:
fmd- MetaData for the field/property to be mapped (if any)table- The table storing this mapping (if any)clr- the ClassLoaderResolver
-
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.
-
addColumns
protected void addColumns()
-
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
-
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 datastore mappings.- Overrides:
getJavaTypeForColumnMappingin classSingleFieldMultiMapping- Parameters:
index- requested column index.- Returns:
- the name of java-type for the requested column.
-
getValueForColumnMapping
public Object getValueForColumnMapping(org.datanucleus.NucleusContext nucleusCtx, int index, Object value)
Method to return the value to be stored in the specified datastore index given the overall value for this java type.- Overrides:
getValueForColumnMappingin classJavaTypeMapping- Parameters:
index- The datastore indexvalue- The overall value for this java typenucleusCtx- Context- Returns:
- The value for this datastore index
-
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 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:JavaTypeMappingObtains a value fromdatastoreResultsat position specified byexprIndex.- Overrides:
getObjectin classJavaTypeMapping- Parameters:
ec- ExecutionContextresultSet- ResultSetexprIndex- the position of the value in the result- Returns:
- the value
-
-