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 String
EXTENSION_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 Object
deserialiseFieldValue(org.datanucleus.state.DNStateManager sm)
Method to deserialise the value from file and return it.protected String
getFilenameForStateManager(org.datanucleus.state.DNStateManager sm)
Class
getJavaType()
Accessor for the java type being mapped.boolean
includeInFetchStatement()
Accessor for whether this mapping is to be included in any fetch statement.boolean
includeInInsertStatement()
Accessor for whether this mapping is to be included in the insert statement.boolean
includeInUpdateStatement()
Accessor for whether this mapping is to be included in the update statement.void
initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd, Table table, org.datanucleus.ClassLoaderResolver clr)
Initialize this JavaTypeMapping for the supplied table and field/property metadata.void
postFetch(org.datanucleus.state.DNStateManager sm)
Method called after the retrieval of the object, so that additional operations can be performed if necessary.void
postInsert(org.datanucleus.state.DNStateManager sm)
Method called after the insert of the object so that additional operations can be performed if necessary.void
postUpdate(org.datanucleus.state.DNStateManager sm)
Method called after the update of the object, so that additional operations can be performed if necessary.void
preDelete(org.datanucleus.state.DNStateManager sm)
Method called before the delete of objects, so that additional operations can be performed if necessary.protected void
serialiseFieldValue(org.datanucleus.state.DNStateManager sm, Object value)
Method to serialise the value from StateManager 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, performSetPostProcessing, representableAsStringLiteralInStatement, requiresSetPostProcessing, setAbsFieldNumber, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemberMetaData, setObject, setObject, setReferenceMapping, setRoleForMember, setShort, setString, setTable
-
-
-
-
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:JavaTypeMapping
Initialize 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:
initialize
in 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:JavaTypeMapping
Accessor for whether this mapping is to be included in any fetch statement.- Overrides:
includeInFetchStatement
in classJavaTypeMapping
- Returns:
- Whether to include this mapping in a fetch statement
-
includeInUpdateStatement
public boolean includeInUpdateStatement()
Description copied from class:JavaTypeMapping
Accessor for whether this mapping is to be included in the update statement.- Overrides:
includeInUpdateStatement
in classJavaTypeMapping
- Returns:
- Whether to include in update statement
-
includeInInsertStatement
public boolean includeInInsertStatement()
Description copied from class:JavaTypeMapping
Accessor for whether this mapping is to be included in the insert statement.- Overrides:
includeInInsertStatement
in classJavaTypeMapping
- Returns:
- Whether to include in insert statement
-
getJavaType
public Class getJavaType()
Description copied from class:JavaTypeMapping
Accessor 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:
getJavaType
in classJavaTypeMapping
- Returns:
- The java type
-
postInsert
public void postInsert(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the insert of the object so that additional operations can be performed if necessary.- Specified by:
postInsert
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
postFetch
public void postFetch(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the retrieval of the object, so that additional operations can be performed if necessary.- Specified by:
postFetch
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
postUpdate
public void postUpdate(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called after the update of the object, so that additional operations can be performed if necessary.- Specified by:
postUpdate
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
preDelete
public void preDelete(org.datanucleus.state.DNStateManager sm)
Description copied from interface:MappingCallbacks
Method called before the delete of objects, so that additional operations can be performed if necessary.- Specified by:
preDelete
in interfaceMappingCallbacks
- Parameters:
sm
- StateManager of the owner
-
getFilenameForStateManager
protected String getFilenameForStateManager(org.datanucleus.state.DNStateManager sm)
-
serialiseFieldValue
protected void serialiseFieldValue(org.datanucleus.state.DNStateManager sm, Object value)
Method to serialise the value from StateManager to file.- Parameters:
sm
- StateManagervalue
- The value being serialised
-
deserialiseFieldValue
protected Object deserialiseFieldValue(org.datanucleus.state.DNStateManager sm)
Method to deserialise the value from file and return it.- Parameters:
sm
- StateManager to get the value for- Returns:
- The value currently stored
-
-