Class SerialisedLocalFileMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
-
- org.datanucleus.store.rdbms.mapping.java.SerialisedLocalFileMapping
-
- All Implemented Interfaces:
MappingCallbacks
public class SerialisedLocalFileMapping extends JavaTypeMapping implements MappingCallbacks
Mapping where we want to serialise a (Serializable) field to a local file. Since the field will be stored in the local file system then this will have no "datastore mapping" (i.e column) as such. The user defines the folder in which values of this field will be stored in metadata, and the filename in that folder is basically the "id" of the owning object. Assumes that the user is not storing multiple fields in the same folder.Handling roll back
Whenever an insert/update/delete is performed it registers a listener on any active transaction and allows a hook to attempt to roll back any changes to the value before that operation.
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXTENSION_SERIALIZE_TO_FOLDER-
Fields inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type
-
-
Constructor Summary
Constructors Constructor Description SerialisedLocalFileMapping()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectdeserialiseFieldValue(org.datanucleus.state.ObjectProvider op)Method to deserialise the value from file and return it.protected StringgetFilenameForObjectProvider(org.datanucleus.state.ObjectProvider op)ClassgetJavaType()Accessor for the java type being mapped.booleanincludeInFetchStatement()Accessor for whether this mapping is to be included in any fetch statement.booleanincludeInInsertStatement()Accessor for whether this mapping is to be included in the insert statement.booleanincludeInUpdateStatement()Accessor for whether this mapping is to be included in the update statement.voidinitialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)Initialize this JavaTypeMapping for the supplied table and field/property metadata.voidinsertPostProcessing(org.datanucleus.state.ObjectProvider op)Perform any INSERT post processing as required by constituent ColumnMappings.voidpostFetch(org.datanucleus.state.ObjectProvider op)Method called after the retrieval of the object, so that additional operations can be performed if necessary.voidpostInsert(org.datanucleus.state.ObjectProvider op)Method called after the insert of the object so that additional operations can be performed if necessary.voidpostUpdate(org.datanucleus.state.ObjectProvider op)Method called after the update of the object, so that additional operations can be performed if necessary.voidpreDelete(org.datanucleus.state.ObjectProvider op)Method called before the delete of objects, so that additional operations can be performed if necessary.protected voidserialiseFieldValue(org.datanucleus.state.ObjectProvider op, Object value)Method to serialise the value from the ObjectProvider to file.-
Methods inherited from class org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
addColumnMapping, equals, failureMessage, getAbsoluteFieldNumber, getBoolean, getByte, getChar, getColumnMapping, getColumnMappings, getColumnMetaDataForMember, getDouble, getFloat, getInt, getJavaTypeForColumnMapping, getLong, getMemberMetaData, getNumberOfColumnMappings, getObject, getObject, getReferenceMapping, getRoleForMember, getShort, getStoreManager, getString, getTable, getType, getValueForColumnMapping, hashCode, hasSimpleDatastoreRepresentation, initialize, isNullable, isSerialised, representableAsStringLiteralInStatement, requiresInsertPostProcessing, requiresUpdatePostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setObject, setObject, setReferenceMapping, setRoleForMember, setShort, setString, setTable, updatePostProcessing
-
-
-
-
Field Detail
-
EXTENSION_SERIALIZE_TO_FOLDER
public static final String EXTENSION_SERIALIZE_TO_FOLDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, 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:
mmd- MetaData for the field/property to be mapped (if any)table- The table storing this mapping (if any)clr- the ClassLoaderResolver
-
includeInFetchStatement
public boolean includeInFetchStatement()
Description copied from class:JavaTypeMappingAccessor for whether this mapping is to be included in any fetch statement.- Overrides:
includeInFetchStatementin classJavaTypeMapping- Returns:
- Whether to include this mapping in a fetch statement
-
includeInUpdateStatement
public boolean includeInUpdateStatement()
Description copied from class:JavaTypeMappingAccessor for whether this mapping is to be included in the update statement.- Overrides:
includeInUpdateStatementin classJavaTypeMapping- Returns:
- Whether to include in update statement
-
includeInInsertStatement
public boolean includeInInsertStatement()
Description copied from class:JavaTypeMappingAccessor for whether this mapping is to be included in the insert statement.- Overrides:
includeInInsertStatementin classJavaTypeMapping- Returns:
- Whether to include in insert statement
-
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
-
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)
Description copied from interface:MappingCallbacksMethod called after the insert of the object so that additional operations can be performed if necessary.- Specified by:
postInsertin interfaceMappingCallbacks- Parameters:
op- ObjectProvider of the owner
-
postFetch
public void postFetch(org.datanucleus.state.ObjectProvider op)
Description copied from interface:MappingCallbacksMethod called after the retrieval of the object, so that additional operations can be performed if necessary.- Specified by:
postFetchin interfaceMappingCallbacks- Parameters:
op- ObjectProvider of the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.ObjectProvider op)
Description copied from interface:MappingCallbacksMethod called after the update of the object, so that additional operations can be performed if necessary.- Specified by:
postUpdatein interfaceMappingCallbacks- Parameters:
op- ObjectProvider of the owner
-
preDelete
public void preDelete(org.datanucleus.state.ObjectProvider op)
Description copied from interface:MappingCallbacksMethod called before the delete of objects, so that additional operations can be performed if necessary.- Specified by:
preDeletein interfaceMappingCallbacks- Parameters:
op- ObjectProvider of the owner
-
getFilenameForObjectProvider
protected String getFilenameForObjectProvider(org.datanucleus.state.ObjectProvider op)
-
serialiseFieldValue
protected void serialiseFieldValue(org.datanucleus.state.ObjectProvider op, Object value)Method to serialise the value from the ObjectProvider to file.- Parameters:
op- The ObjectProvidervalue- The value being serialised
-
deserialiseFieldValue
protected Object deserialiseFieldValue(org.datanucleus.state.ObjectProvider op)
Method to deserialise the value from file and return it.- Parameters:
op- The ObjectProvider to get the value for- Returns:
- The value currently stored
-
-