Class SerialisedLocalFileMapping
java.lang.Object
org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping
org.datanucleus.store.rdbms.mapping.java.SerialisedLocalFileMapping
- All Implemented Interfaces:
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
FieldsFields inherited from class JavaTypeMapping
absFieldNumber, columnMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdeserialiseFieldValue(org.datanucleus.state.DNStateManager sm) Method to deserialise the value from file and return it.protected StringgetFilenameForStateManager(org.datanucleus.state.DNStateManager sm) Accessor for the java type being mapped.booleanAccessor for whether this mapping is to be included in any fetch statement.booleanAccessor for whether this mapping is to be included in the insert statement.booleanAccessor 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.voidpostFetch(org.datanucleus.state.DNStateManager sm) Method called after the retrieval of the object, so that additional operations can be performed if necessary.voidpostInsert(org.datanucleus.state.DNStateManager sm) Method called after the insert of the object so that additional operations can be performed if necessary.voidpostUpdate(org.datanucleus.state.DNStateManager sm) Method called after the update of the object, so that additional operations can be performed if necessary.voidpreDelete(org.datanucleus.state.DNStateManager sm) Method called before the delete of objects, so that additional operations can be performed if necessary.protected voidserialiseFieldValue(org.datanucleus.state.DNStateManager sm, Object value) Method to serialise the value from StateManager to file.Methods inherited from class 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, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setObject, setObject, setReferenceMapping, setRoleForMember, setShort, setString, setTable
-
Field Details
-
EXTENSION_SERIALIZE_TO_FOLDER
- See Also:
-
folderName
String folderName
-
-
Constructor Details
-
SerialisedLocalFileMapping
public SerialisedLocalFileMapping()
-
-
Method Details
-
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
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
-
postInsert
public void postInsert(org.datanucleus.state.DNStateManager sm) 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:
sm- StateManager of the owner
-
postFetch
public void postFetch(org.datanucleus.state.DNStateManager sm) 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:
sm- StateManager of the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.DNStateManager sm) 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:
sm- StateManager of the owner
-
preDelete
public void preDelete(org.datanucleus.state.DNStateManager sm) 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:
sm- StateManager of the owner
-
getFilenameForStateManager
-
serialiseFieldValue
Method to serialise the value from StateManager to file.- Parameters:
sm- StateManagervalue- The value being serialised
-
deserialiseFieldValue
Method to deserialise the value from file and return it.- Parameters:
sm- StateManager to get the value for- Returns:
- The value currently stored
-