Class PersistableMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.MultiMapping
-
- org.datanucleus.store.rdbms.mapping.java.PersistableMapping
-
- All Implemented Interfaces:
MappingCallbacks
- Direct Known Subclasses:
PersistableIdMapping
public class PersistableMapping extends MultiMapping implements MappingCallbacks
Maps a field storing a persistable object. TODO Move column creation for join table collection/map/array of PC to this class
-
-
Field Summary
Fields Modifier and Type Field Description protected org.datanucleus.metadata.AbstractClassMetaDatacmdClassMetaData for the represented class; creating a new one on each getObject invoke is expensive-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.MultiMapping
javaTypeMappings, numberOfColumnMappings
-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description PersistableMapping()Create a new empty PersistableMapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.datanucleus.metadata.AbstractClassMetaDatagetClassMetaData()Metadata for the class that this represents an object of.ClassgetJavaType()Accessor for the java type being mapped.ObjectgetObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] resultIndexes)Returns an instance of a persistable class.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 mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping with the given DatastoreAdapter for the given metadata.voidinitialize(RDBMSStoreManager storeMgr, String type)Initialise this JavaTypeMapping with the given StoreManager for the given type.voidinsertPostProcessing(org.datanucleus.state.ObjectProvider op)Perform any INSERT post processing as required by constituent ColumnMappings.voidpostFetch(org.datanucleus.state.ObjectProvider op)Method executed just after a fetch of the owning object, allowing any necessary action to this field and the object stored in it.voidpostInsert(org.datanucleus.state.ObjectProvider op)Method executed just after the insert of the owning object, allowing any necessary action to this field and the object stored in it.voidpostUpdate(org.datanucleus.state.ObjectProvider op)Method executed just afer any update of the owning object, allowing any necessary action to this field and the object stored in it.voidpreDelete(org.datanucleus.state.ObjectProvider op)Method executed just before the owning object is deleted, allowing tidying up of any relation information.protected voidprepareColumnMapping(org.datanucleus.ClassLoaderResolver clr)Method to prepare the PC mapping and add its associated column mappings.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] param, Object value)Method to set an object in the datastore.voidsetObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] param, Object value, org.datanucleus.state.ObjectProvider ownerOP, int ownerFieldNumber)Method to set an object reference (FK) in the datastore.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.MultiMapping
addJavaTypeMapping, getColumnMapping, getColumnMappings, getJavaTypeMapping, getNumberOfColumnMappings
-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getBoolean, getByte, getChar, getColumnMetaDataForMember, getDouble, getFloat, getInt, getJavaTypeForColumnMapping, getLong, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getShort, getStoreManager, getString, getTable, getType, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, isNullable, isSerialised, representableAsStringLiteralInStatement, requiresInsertPostProcessing, requiresUpdatePostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setReferenceMapping, setRoleForMember, setShort, setString, setTable, updatePostProcessing
-
-
-
-
Method Detail
-
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
-
getClassMetaData
public org.datanucleus.metadata.AbstractClassMetaData getClassMetaData()
Metadata for the class that this represents an object of.- Returns:
- ClassMetaData
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping with the given DatastoreAdapter for the given metadata.- Overrides:
initializein classJavaTypeMapping- Parameters:
mmd- MetaData for the field/property to be mapped (if any)table- The datastore container 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.
-
prepareColumnMapping
protected void prepareColumnMapping(org.datanucleus.ClassLoaderResolver clr)
Method to prepare the PC mapping and add its associated column mappings.- Parameters:
clr- The ClassLoaderResolver
-
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:
nucleusCtx- Contextindex- The datastore indexvalue- The overall value for this java type- Returns:
- The value for this datastore index
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] param, Object value)Method to set an object in the datastore.- Overrides:
setObjectin classJavaTypeMapping- Parameters:
ec- The ExecutionContextps- The Prepared Statementparam- The parameter ids in the statementvalue- The value to put in the statement at these ids- Throws:
org.datanucleus.exceptions.NotYetFlushedException- if an object hasn't yet been flushed to the datastore
-
setObject
public void setObject(org.datanucleus.ExecutionContext ec, PreparedStatement ps, int[] param, Object value, org.datanucleus.state.ObjectProvider ownerOP, int ownerFieldNumber)Method to set an object reference (FK) in the datastore.- Overrides:
setObjectin classJavaTypeMapping- Parameters:
ec- The ExecutionContextps- The Prepared Statementparam- The parameter ids in the statementvalue- The value to put in the statement at these idsownerOP- ObjectProvider for the owner objectownerFieldNumber- Field number of this PC object in the owner- Throws:
org.datanucleus.exceptions.NotYetFlushedException- if an object hasn't yet been flushed to the datastore
-
getObject
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet rs, int[] resultIndexes)
Returns an instance of a persistable class. Processes the FK field and generates the id of the object from the result values, and hence the object itself. TODO Pass in the discriminator/version columns also where available- Overrides:
getObjectin classJavaTypeMapping- Parameters:
ec- execution contextrs- The ResultSetresultIndexes- indexes in the ResultSet to retrieve- Returns:
- The persistable object
-
postFetch
public void postFetch(org.datanucleus.state.ObjectProvider op)
Method executed just after a fetch of the owning object, allowing any necessary action to this field and the object stored in it.- Specified by:
postFetchin interfaceMappingCallbacks- Parameters:
op- ObjectProvider for the owner.
-
insertPostProcessing
public void insertPostProcessing(org.datanucleus.state.ObjectProvider op)
Description copied from class:JavaTypeMappingPerform any INSERT post processing as required by constituent ColumnMappings. TODO Not yet utilised, see RDBMS-14- Specified by:
insertPostProcessingin interfaceMappingCallbacks- Overrides:
insertPostProcessingin classJavaTypeMapping- Parameters:
op- ObjectProvider of the object with this mapping
-
postInsert
public void postInsert(org.datanucleus.state.ObjectProvider op)
Method executed just after the insert of the owning object, allowing any necessary action to this field and the object stored in it.- Specified by:
postInsertin interfaceMappingCallbacks- Parameters:
op- ObjectProvider for the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.ObjectProvider op)
Method executed just afer any update of the owning object, allowing any necessary action to this field and the object stored in it.- Specified by:
postUpdatein interfaceMappingCallbacks- Parameters:
op- ObjectProvider for the owner
-
preDelete
public void preDelete(org.datanucleus.state.ObjectProvider op)
Method executed just before the owning object is deleted, allowing tidying up of any relation information.- Specified by:
preDeletein interfaceMappingCallbacks- Parameters:
op- ObjectProvider for the owner
-
-