Package org.apache.openjpa.abstractstore
Class AbstractStoreManager
- java.lang.Object
-
- org.apache.openjpa.abstractstore.AbstractStoreManager
-
- All Implemented Interfaces:
StoreManager
,Closeable
- Direct Known Subclasses:
XMLStoreManager
public abstract class AbstractStoreManager extends java.lang.Object implements StoreManager
Abstract store manager implementation to ease development of custom OpenJPA back-ends. A concrete subclass must define implementations for the following methods:StoreManager.exists(org.apache.openjpa.kernel.OpenJPAStateManager, java.lang.Object)
initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
flush(Collection,Collection,Collection,Collection,Collection)
executeExtent(org.apache.openjpa.meta.ClassMetaData, boolean, org.apache.openjpa.kernel.FetchConfiguration)
open()
has been called. Store manager instances might be created to call metadata methods such asnewConfiguration()
orgetUnsupportedOptions()
and never opened. These instances should not consume any data store resources. Notes:- The
StoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
method is responsible for creating new instances of objects freshly loaded from the database. The method will be invoked with aOpenJPAStateManager
that the newly-loaded object should be associated with. To create the new object and set up this association correctly, the implementation should use theOpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState)
method. - If your data store supports some sort of transaction or
unit of work, you should override the
begin()
,commit()
, androllback()
methods. - This class provides no infrastructure support for optimistic
transactions. To provide optimistic transaction support:
- Override
beginOptimistic()
,rollbackOptimistic()
, andsyncVersion(org.apache.openjpa.kernel.OpenJPAStateManager, java.lang.Object)
. - Override
getUnsupportedOptions()
to not includeOpenJPAConfiguration.OPTION_OPTIMISTIC
in the list of unsupported options. - Ensure that your flush implementation sets the next
version for each modified object via the
OpenJPAStateManager.setNextVersion(java.lang.Object)
method. - If your version object does not implement
Comparable
, overridecompareVersion(org.apache.openjpa.kernel.OpenJPAStateManager, java.lang.Object, java.lang.Object)
, which relies on theComparable.compareTo(T)
method.
- Override
- If your data store supports a mechanism for automatically
generating and managing identity values (or if you want to
provide that facility on top of your data store), implement
the
getDataStoreIdSequence(org.apache.openjpa.meta.ClassMetaData)
method if you want to use along
as your datastore identity type and are happy with OpenJPA'sId
class. To use another datastore identity type, overridegetManagedType(java.lang.Object)
,getDataStoreIdType(org.apache.openjpa.meta.ClassMetaData)
,copyDataStoreId(java.lang.Object, org.apache.openjpa.meta.ClassMetaData)
, andnewDataStoreId(java.lang.Object, org.apache.openjpa.meta.ClassMetaData)
instead. In either case, overridegetUnsupportedOptions()
to not includeOpenJPAConfiguration.OPTION_ID_DATASTORE
in the list of unsupported options. - If your data store does not support queries (or if you do
not want to convert OpenJPA's query parse tree into a
datastore-specific query), you still have two options in terms
of query execution:
- In-memory execution: If you execute a query against an extent or a class, OpenJPA will automatically load the full extent of objects into memory and execute the query in memory.
- openjpa.MethodQL: MethodQL allows
you to use the query APIs to execute a method that finds
data in your back-end and returns that data as a
ResultList
. For more details on MethodQL, see the OpenJPA Reference Guide.
- Since:
- 0.3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected StoreContext
ctx
-
Fields inherited from interface org.apache.openjpa.kernel.StoreManager
FORCE_LOAD_ALL, FORCE_LOAD_DFG, FORCE_LOAD_NONE, FORCE_LOAD_REFRESH, VERSION_DIFFERENT, VERSION_EARLIER, VERSION_LATER, VERSION_SAME
-
-
Constructor Summary
Constructors Constructor Description AbstractStoreManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
assignDataStoreId(OpenJPAStateManager sm, java.lang.Object val)
Assign a new datastore identity to the given instance.boolean
assignField(OpenJPAStateManager sm, int field, boolean preFlush)
Assign a value to the given field.boolean
assignObjectId(OpenJPAStateManager sm, boolean preFlush)
Assign an object id to the given new instance.void
beforeStateChange(OpenJPAStateManager sm, PCState fromState, PCState toState)
Notification that the given state manager is about to change its lifecycle state.void
begin()
OpenJPA assumes that after this method is invoked, all data accesses through this store manager will be part of a single unit of work that can be rolled back.void
beginOptimistic()
No-op implementation.boolean
cancelAll()
Returnsfalse
.void
close()
Free any resources this store manager is using.void
commit()
This is a no-op implementation.int
compareVersion(OpenJPAStateManager state, java.lang.Object v1, java.lang.Object v2)
Castsv1
andv2
toComparable
, and invokesv1.compareTo (v2)
.java.lang.Object
copyDataStoreId(java.lang.Object oid, ClassMetaData meta)
Copy the given object id value.abstract ResultObjectProvider
executeExtent(ClassMetaData meta, boolean subs, FetchConfiguration fetch)
Create aResultObjectProvider
that can return all instances oftype
, optionally including subclasses as defined bysubclasses
.java.util.Collection<java.lang.Exception>
flush(java.util.Collection<OpenJPAStateManager> sms)
Breaks downstates
based on the objects' current states, and delegates toflush(Collection,Collection,Collection,Collection,Collection)
.protected abstract java.util.Collection<java.lang.Exception>
flush(java.util.Collection<OpenJPAStateManager> pNew, java.util.Collection<OpenJPAStateManager> pNewUpdated, java.util.Collection<OpenJPAStateManager> pNewFlushedDeleted, java.util.Collection<OpenJPAStateManager> pDirty, java.util.Collection<OpenJPAStateManager> pDeleted)
Responsible for writing modifications happened back to the data store.java.lang.Object
getClientConnection()
Returnsnull
.StoreContext
getContext()
Returns theStoreContext
that this store manager is associated with.Seq
getDataStoreIdSequence(ClassMetaData forClass)
Returns the system-configured sequence.java.lang.Class<?>
getDataStoreIdType(ClassMetaData meta)
Return the class used by this StoreManager for datastore identity values.java.lang.Class<?>
getManagedType(java.lang.Object oid)
Return the persistent class for the given data store identity value.protected java.lang.String
getPlatform()
Returns a string name to identify the platform of this store manager.protected java.util.Collection<java.lang.String>
getUnsupportedOptions()
Returns a set of option names that this store manager does not support.Seq
getValueSequence(FieldMetaData forField)
Returns null.abstract boolean
initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch, java.lang.Object edata)
This method is invoked when OpenJPA needs to load an object whose identity is known but which has not yet been loaded from the data store.abstract boolean
load(OpenJPAStateManager sm, java.util.BitSet fields, FetchConfiguration fetch, int lockLevel, java.lang.Object edata)
This method is invoked when OpenJPA needs to load additional data into an object that has already been at least partially loaded by a previousinitialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
invocation.java.util.Collection<java.lang.Object>
loadAll(java.util.Collection<OpenJPAStateManager> sms, PCState state, int load, FetchConfiguration fetch, java.lang.Object edata)
This implementation just delegates to the proper singular method (StoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
) depending on each state manager's state.protected OpenJPAConfiguration
newConfiguration()
Return a new configuration instance for this runtime.java.lang.Object
newDataStoreId(java.lang.Object val, ClassMetaData meta)
Create a new unique datastore identity for the given type from the given oid value (presumably pk, stringified oid, or oid instance).FetchConfiguration
newFetchConfiguration()
Return a fetch configuration suitable for this runtime.StoreQuery
newQuery(java.lang.String language)
Return a query implementation suitable for this store.protected void
open()
No-op implementation.void
releaseConnection()
Override to release previously-retained connection.void
retainConnection()
Override to retain a dedicated connection.void
rollback()
This is a no-op implementation.void
rollbackOptimistic()
No-op implementation.void
setContext(StoreContext ctx)
Set a reference to the corresponding context.boolean
syncVersion(OpenJPAStateManager sm, java.lang.Object edata)
Since this store manager does not provide optimistic locking support, this method always returnstrue
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.kernel.StoreManager
exists, isCached
-
-
-
-
Field Detail
-
ctx
protected StoreContext ctx
-
-
Method Detail
-
setContext
public final void setContext(StoreContext ctx)
Description copied from interface:StoreManager
Set a reference to the corresponding context. This method will be called before the store manager is used. The store manager is responsible for pulling any necessary configuration data from the context, including the transaction mode and connection retain mode.- Specified by:
setContext
in interfaceStoreManager
-
getContext
public StoreContext getContext()
Returns theStoreContext
that this store manager is associated with.
-
open
protected void open()
No-op implementation. Ready this store manager for persistent operations.
-
beginOptimistic
public void beginOptimistic()
No-op implementation. Override this method to provide optimistic locking semantics for your data store if you need notification of the beginning of an optimistic transaction.- Specified by:
beginOptimistic
in interfaceStoreManager
-
rollbackOptimistic
public void rollbackOptimistic()
No-op implementation. Override this method to provide optimistic locking semantics for your data store if you need notification of a rollback of an optimistic transaction beforebegin()
is invoked.- Specified by:
rollbackOptimistic
in interfaceStoreManager
-
begin
public void begin()
OpenJPA assumes that after this method is invoked, all data accesses through this store manager will be part of a single unit of work that can be rolled back. This is a no-op implementation. If your data store does not support any concept of locking or transactions, you need not override this method.- Specified by:
begin
in interfaceStoreManager
-
commit
public void commit()
This is a no-op implementation. If your data store does not have a concept of transactions or a unit of work, you need not override this method. If it does, then override this method to notify the data store that the current transaction should be committed.- Specified by:
commit
in interfaceStoreManager
-
rollback
public void rollback()
This is a no-op implementation. If your data store does not have a concept of transactions or a unit of work, you need not override this method. If it does, then override this method to notify the data store that the current transaction should be rolled back.- Specified by:
rollback
in interfaceStoreManager
-
syncVersion
public boolean syncVersion(OpenJPAStateManager sm, java.lang.Object edata)
Since this store manager does not provide optimistic locking support, this method always returnstrue
.- Specified by:
syncVersion
in interfaceStoreManager
- Parameters:
sm
- the instance to checkedata
- the current execution data, or null if not given to the calling method of the context- Returns:
- true if the instance still exists in the datastore and is up-to-date, false otherwise
-
initialize
public abstract boolean initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch, java.lang.Object edata)
This method is invoked when OpenJPA needs to load an object whose identity is known but which has not yet been loaded from the data store.sm
is a partially-set-up state manager for this object. The ID and least-derived type information for the instance to load can be obtained by invokingsm.getObjectId()
andsm.getMetaData()
. When implementing this method, load the data for this object from the data store, determine the most-derived subclass of the newly-loaded data, and then use theOpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState)
method to populatesm
with a new instance of the appropriate type. OnceOpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState)
has been invoked, proceed to load field data intosm
as in theload(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
method, by usingOpenJPAStateManager.store(int, java.lang.Object)
(or the appropriateOpenJPAStateManager.storetype
method) to put the data into the object.- Specified by:
initialize
in interfaceStoreManager
- Parameters:
sm
- the instance to initializestate
- the lifecycle state to initialize the state manager withfetch
- configuration for how to load the instanceedata
- the current execution data, or null if not given to the calling method of the broker- Returns:
- true if the matching instance exists in the data store, false otherwise
-
load
public abstract boolean load(OpenJPAStateManager sm, java.util.BitSet fields, FetchConfiguration fetch, int lockLevel, java.lang.Object edata)
This method is invoked when OpenJPA needs to load additional data into an object that has already been at least partially loaded by a previousinitialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
invocation. Load data intosm
by usingOpenJPAStateManager.store(int, java.lang.Object)
(or the appropriateOpenJPAStateManager.storetype
method) to put the data into the object.- Specified by:
load
in interfaceStoreManager
- Parameters:
sm
- the instance to loadfields
- set of fields to load; all field indexes in this set must be loaded; this set is mutablefetch
- the fetch configuration to use when loading related objectslockLevel
- attempt to load simple fields at this lock level; relations should be loaded at the read lock level of the fetch configurationedata
- the current execution data, or null if not given to the calling method of the broker- Returns:
- false if the object no longer exists in the database, true otherwise
-
loadAll
public java.util.Collection<java.lang.Object> loadAll(java.util.Collection<OpenJPAStateManager> sms, PCState state, int load, FetchConfiguration fetch, java.lang.Object edata)
This implementation just delegates to the proper singular method (StoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
) depending on each state manager's state. If your data store provides bulk loading APIs, overriding this method to be more clever may be advantageous.- Specified by:
loadAll
in interfaceStoreManager
- Parameters:
sms
- the state manager instances to loadstate
- the lifecycle state to initialize uninitialized state managers with; may be null if no uninitialized instances are included insms
load
- one of the FORCE_LOAD_* constants describing the fields to force-load if this is a refresh or retrieve actionfetch
- the current fetch configuration to use when loading related objectsedata
- the current execution data, or null if not given to the calling method of the broker- Returns:
- a collection of the state manager identities for which no data store record exists
- See Also:
ImplHelper.loadAll(java.util.Collection, org.apache.openjpa.kernel.StoreManager, org.apache.openjpa.kernel.PCState, int, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
-
flush
public java.util.Collection<java.lang.Exception> flush(java.util.Collection<OpenJPAStateManager> sms)
Breaks downstates
based on the objects' current states, and delegates toflush(Collection,Collection,Collection,Collection,Collection)
.- Specified by:
flush
in interfaceStoreManager
- See Also:
org.apache.openjpa.util.ApplicationIds#assign()
-
beforeStateChange
public void beforeStateChange(OpenJPAStateManager sm, PCState fromState, PCState toState)
Description copied from interface:StoreManager
Notification that the given state manager is about to change its lifecycle state. The store manager is not required to do anything in this method, but some back ends may need to.- Specified by:
beforeStateChange
in interfaceStoreManager
-
assignObjectId
public boolean assignObjectId(OpenJPAStateManager sm, boolean preFlush)
Description copied from interface:StoreManager
Assign an object id to the given new instance. Return false if the instance cannot be assigned an identity because a flush is required (for example, the identity is determined by the datastore on insert). For application identity instances, the assigned object id should be based on field state. The implementation is responsible for using the proper value strategy according to the instance metadata. This method is called the first time a user requests the oid of a new instance before flush.- Specified by:
assignObjectId
in interfaceStoreManager
preFlush
- whether this assignment is being requested by the system as part of pre-flush activities, and can be ignored if it is more efficient to assign withinStoreManager.flush(java.util.Collection<org.apache.openjpa.kernel.OpenJPAStateManager>)
- See Also:
ImplHelper.generateFieldValue(org.apache.openjpa.kernel.StoreContext, org.apache.openjpa.meta.FieldMetaData)
,ImplHelper.generateIdentityValue(org.apache.openjpa.kernel.StoreContext, org.apache.openjpa.meta.ClassMetaData, int)
,org.apache.openjpa.util.ApplicationIds#assign()
-
assignDataStoreId
protected boolean assignDataStoreId(OpenJPAStateManager sm, java.lang.Object val)
Assign a new datastore identity to the given instance. This given value may be null.
-
assignField
public boolean assignField(OpenJPAStateManager sm, int field, boolean preFlush)
Description copied from interface:StoreManager
Assign a value to the given field. Return false if the value cannot be assigned because a flush is required (for example, the field value is determined by the datastore on insert). This method is called the first time a user requests the value of a field with a value-strategy on a new instance before flush.- Specified by:
assignField
in interfaceStoreManager
preFlush
- whether this assignment is being requested by the system as part of pre-flush activities, and can be ignored if it is more efficient to assign withinStoreManager.flush(java.util.Collection<org.apache.openjpa.kernel.OpenJPAStateManager>)
- See Also:
ImplHelper.generateFieldValue(org.apache.openjpa.kernel.StoreContext, org.apache.openjpa.meta.FieldMetaData)
-
getManagedType
public java.lang.Class<?> getManagedType(java.lang.Object oid)
Description copied from interface:StoreManager
Return the persistent class for the given data store identity value. If the given value is not a datastore identity object, return null.- Specified by:
getManagedType
in interfaceStoreManager
-
getDataStoreIdType
public java.lang.Class<?> getDataStoreIdType(ClassMetaData meta)
Description copied from interface:StoreManager
Return the class used by this StoreManager for datastore identity values. The given metadata may be null, in which case the return value should the common datastore identity class for all classes, or null if this store manager does not use a common identity class.- Specified by:
getDataStoreIdType
in interfaceStoreManager
-
copyDataStoreId
public java.lang.Object copyDataStoreId(java.lang.Object oid, ClassMetaData meta)
Description copied from interface:StoreManager
Copy the given object id value. Use the described type of the given metadata, which may be a subclass of the given oid's described type.- Specified by:
copyDataStoreId
in interfaceStoreManager
-
newDataStoreId
public java.lang.Object newDataStoreId(java.lang.Object val, ClassMetaData meta)
Description copied from interface:StoreManager
Create a new unique datastore identity for the given type from the given oid value (presumably pk, stringified oid, or oid instance).- Specified by:
newDataStoreId
in interfaceStoreManager
-
retainConnection
public void retainConnection()
Override to retain a dedicated connection.- Specified by:
retainConnection
in interfaceStoreManager
-
releaseConnection
public void releaseConnection()
Override to release previously-retained connection.- Specified by:
releaseConnection
in interfaceStoreManager
-
getClientConnection
public java.lang.Object getClientConnection()
Returnsnull
. If your data store can provide a distinct connection object, return it here.- Specified by:
getClientConnection
in interfaceStoreManager
-
executeExtent
public abstract ResultObjectProvider executeExtent(ClassMetaData meta, boolean subs, FetchConfiguration fetch)
Create aResultObjectProvider
that can return all instances oftype
, optionally including subclasses as defined bysubclasses
. The implementation of the result provider will typically execute some sort of data store query to find all the applicable objects, loop through the results, extracting object IDs from the data, and invokeStoreContext.find(Object,FetchConfiguration,BitSet,Object,int)
on each OID. When invoking this method, the first argument is the OID. The second is the given fetch configuration. The third argument is a mask of fields to exclude from loading; it will typically be null. The fourth argument is an object that will be passed through toinitialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orload(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
, and typically will contain the actual data to load. For example, for a JDBC-based store manager, this might be the result set that is being iterated over. If this argument isnull
, then theinitialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orload(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
method will have to issue another command to the data store in order to fetch the data to be loaded.- Specified by:
executeExtent
in interfaceStoreManager
-
newQuery
public StoreQuery newQuery(java.lang.String language)
Description copied from interface:StoreManager
Return a query implementation suitable for this store. If the query is iterated within a data store transaction, returned instances should be locked. Return null if this store does not support native execution of the given language. OpenJPA can execute JPQL in memory even without back end support.- Specified by:
newQuery
in interfaceStoreManager
- Parameters:
language
- the query language
-
newFetchConfiguration
public FetchConfiguration newFetchConfiguration()
Description copied from interface:StoreManager
Return a fetch configuration suitable for this runtime. Typically will be or extendFetchConfigurationImpl
.- Specified by:
newFetchConfiguration
in interfaceStoreManager
-
compareVersion
public int compareVersion(OpenJPAStateManager state, java.lang.Object v1, java.lang.Object v2)
Castsv1
andv2
toComparable
, and invokesv1.compareTo (v2)
. Ifv1
is less thanv2
, returnsStoreManager.VERSION_EARLIER
. If the same, returnsStoreManager.VERSION_SAME
. Otherwise, returnsStoreManager.VERSION_LATER
. If eitherv1
orv2
arenull
, returnsStoreManager.VERSION_DIFFERENT
.- Specified by:
compareVersion
in interfaceStoreManager
- Parameters:
state
- the state manager for the objectv1
- the first version object to comparev2
- the second version object to compare- Returns:
StoreManager.VERSION_LATER
ifv1
is later thanv2
StoreManager.VERSION_EARLIER
ifv1
is earlier thanv2
StoreManager.VERSION_SAME
ifv1
is the same asv2
StoreManager.VERSION_DIFFERENT
ifv1
is different fromv2
, but the time difference of the versions cannot be determined
-
getDataStoreIdSequence
public Seq getDataStoreIdSequence(ClassMetaData forClass)
Returns the system-configured sequence. To use some other sort of datastore identifier (a GUID, string, or someting of that nature), overridegetManagedType(java.lang.Object)
,getDataStoreIdType(org.apache.openjpa.meta.ClassMetaData)
,copyDataStoreId(java.lang.Object, org.apache.openjpa.meta.ClassMetaData)
,newDataStoreId(java.lang.Object, org.apache.openjpa.meta.ClassMetaData)
.- Specified by:
getDataStoreIdSequence
in interfaceStoreManager
-
getValueSequence
public Seq getValueSequence(FieldMetaData forField)
Returns null.- Specified by:
getValueSequence
in interfaceStoreManager
-
cancelAll
public boolean cancelAll()
Returnsfalse
. If your data store supports cancelling queries, this method should cancel any currently-running queries and returntrue
if any were cancelled.- Specified by:
cancelAll
in interfaceStoreManager
- Returns:
- true if any statements cancelled, false otherwise
-
close
public void close()
Description copied from interface:StoreManager
Free any resources this store manager is using.- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceStoreManager
-
flush
protected abstract java.util.Collection<java.lang.Exception> flush(java.util.Collection<OpenJPAStateManager> pNew, java.util.Collection<OpenJPAStateManager> pNewUpdated, java.util.Collection<OpenJPAStateManager> pNewFlushedDeleted, java.util.Collection<OpenJPAStateManager> pDirty, java.util.Collection<OpenJPAStateManager> pDeleted)
Responsible for writing modifications happened back to the data store. If you do not remove theOpenJPAConfiguration.OPTION_INC_FLUSH
option ingetUnsupportedOptions()
, this will be called only once at the end of a transaction. Otherwise, it may be called periodically throughout the course of a transaction. If this store manager supports optimistic transactions, datastore version information should be updated during flush, and the state manager's version indicator should be updated through theOpenJPAStateManager.setNextVersion(java.lang.Object)
method. This method will only be invoked if there are meaningful changes to store. This differs from the behavior ofStoreManager.flush(java.util.Collection<org.apache.openjpa.kernel.OpenJPAStateManager>)
, which may be invoked with a collection of objects in states that do not require any datastore action (for example, objects in the transient-transactional state).- Parameters:
pNew
- Objects that should be added to the store, and that have not previously been flushed.pNewUpdated
- New objects that have been modified since they were initially flushed. These were inpersistentNew
in an earlier flush invocation.pNewFlushedDeleted
- New objects that have been deleted since they were initially flushed. These were inpersistentNew
in an earlier flush invocation.pDirty
- Objects that were loaded from the data store and have since been modified.pDeleted
- Objects that were loaded from the data store and have since been deleted. These may have been in a previous flush invocation's persistentDirty list.- Returns:
- a collection of exceptions encountered during flushing.
-
newConfiguration
protected OpenJPAConfiguration newConfiguration()
Return a new configuration instance for this runtime. Configuration data is maintained at the factory level and is available to all OpenJPA components; therefore it is a good place to maintain shared resources such as connection pools, etc.
-
getUnsupportedOptions
protected java.util.Collection<java.lang.String> getUnsupportedOptions()
Returns a set of option names that this store manager does not support. By default, returns the following:
-
getPlatform
protected java.lang.String getPlatform()
Returns a string name to identify the platform of this store manager. Returns the class name of this store manager by default.
-
-