Interface OpenJPAEntityManager
- All Superinterfaces:
jakarta.persistence.EntityManager,jakarta.persistence.EntityTransaction
- All Known Subinterfaces:
OpenJPAEntityManagerSPI
- All Known Implementing Classes:
EntityManagerImpl
EntityTransaction, but this extension is
deprecated.- Since:
- 0.4.0
- Author:
- Abe White
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.static final intDeprecated.use theCallbackModeenum instead.static final intDeprecated.use theCallbackModeenum instead.static final intDeprecated.use theCallbackModeenum instead.static final intDeprecated.use theCallbackModeenum instead.static final intDeprecated.use theAutoClearTypeenum instead.static final intDeprecated.use theAutoClearTypeenum instead.static final intDeprecated.use theConnectionRetainModeenum instead.static final intDeprecated.use theConnectionRetainModeenum instead.static final intDeprecated.use theConnectionRetainModeenum instead.static final intDeprecated.use theDetachStateTypeenum instead.static final intDeprecated.use theAutoDetachTypeenum instead.static final intDeprecated.use theAutoDetachTypeenum instead.static final intDeprecated.use theDetachStateTypeenum instead.static final intDeprecated.use theDetachStateTypeenum instead.static final intDeprecated.use theDetachStateTypeenum instead.static final intDeprecated.use theAutoDetachTypeenum instead.static final intDeprecated.use theAutoDetachTypeenum instead.static final intDeprecated.use theRestoreStateTypeenum instead.static final intDeprecated.use theRestoreStateTypeenum instead.static final intDeprecated.use theRestoreStateTypeenum instead. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLifecycleListener(Object listener, Class... classes) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidaddTransactionListener(Object listener) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidbegin()Deprecated.useEntityTransaction.begin()instead:em.getTransaction().begin()voidBegins a store transaction if one isn't already started.booleanCancel all pending data store statements.voidcommit()Deprecated.useEntityTransaction.commit()instead:em.getTransaction().commit()voidDeprecated.useOpenJPAEntityTransaction.commitAndResume()instead:em.getTransaction().commitAndResume()booleancontainsAll(Object... pcs) Whether the given objects are managed.booleancontainsAll(Collection pcs) Whether the given objects are managed.createDynamicQuery(QueryDefinition dynamic) Create an executable query from a dynamically defined query.<T> Extent<T>createExtent(Class<T> cls, boolean subs) Return an extent of the given class, optionally including subclasses.<T> TcreateInstance(Class<T> cls) Create a new instance of typecls.createNamedQuery(String name) createNativeQuery(String sql) createNativeQuery(String sql, Class resultClass) createNativeQuery(String sql, String resultMapping) createQuery(jakarta.persistence.Query query) Create a new query from the given one.createQuery(String query) createQuery(String language, String query) Create a new query in the given language.Object[]Detach the specified objects from the entity manager.detachAll(Collection pcs) Detach the specified objects from the entity manager.<T> TdetachCopy(T pc) Detach the specified object from the entity manager, detaching based on the AutoDetach value specified and returning a copy of the detached entity.voidMake the named field of the given object dirty.voiddirtyClass(Class cls) Mark the given class as dirty within the current transaction.voidEvict the given object.voidevictAll()Evict all clean objects.voidEvict all persistent-clean and persistent-nontransactional instances in the extent of the given class (including subclasses).voidEvict the given objects.voidevictAll(Collection pcs) Evict the given objects.voidEvict all persistent-clean and persistent-nontransactional instances in the givenExtent.<T> T[]Return the objects with the given oids.<T> Collection<T>findAll(Class<T> cls, Collection oids) Return the objects with the given oids.<T> TfindCached(Class<T> cls, Object oid) Return the cached instance for the given oid/object, or null if not cached.Whether to clear state when entering a transaction.AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.Return the current thread's class loader at the time this entity manager was obtained from the factory.Deprecated.cast toOpenJPAEntityManagerSPIinstead.Return the connection in use by the entity manager, or a new connection if none.Return the connection password.Return the connection retain mode for this entity manager.Return the connection user name.Gets the QueryBuilder with OpenJPA-extended capabilities.Detach mode constant to determine which fields are part of the detached graph.Return a set of current dirty instances.Return the factory that produced this entity manager.booleanWhether to also evict an object from the store cache when it is evicted through this entity manager.Return the (mutable) fetch plan for loading objects from this entity manager.getFieldGenerator(Class forClass, String fieldName) Returns aGeneratorfor the generated values of the specified type, or null if the field is not generated.getIdGenerator(Class forClass) Returns aGeneratorfor the datastore identity values of the specified type, or null if the type is unmanaged or its identity cannot be represented by a sequence.booleanWhether to take into account changes in the transaction when executing a query or iterating an extent.intDeprecated.cast toOpenJPAEntityManagerSPIinstead.jakarta.persistence.LockModeTypegetLockMode(Object pc) Return the lock mode of the given instance, or null if not locked.Return a set of all managed instances.booleanWhether the entity manager or its managed instances are used in a multithreaded environment.getNamedGenerator(String name) Return the named generator defined in the metadata.booleanWhether to allow nontransactional access to persistent state.booleanWhether to allow nontransactional changes to persistent state.Return the oid of the given instance.getObjectIdClass(Class pcClass) Return the application identity class the given persistent class uses for object ids, or null if not a type that uses application identity.booleanWhether to use optimistic transactional semantics.booleanWhether dirty objects will be returned in the order they were dirtied.Return a set of instances which will become transactional upon the next transaction.Return the set of classes that have been made persistent in the current transaction.booleanWhether objects accessed during this transaction will be added to the store cache.Return the set of classes that have been deleted in the current transaction.Whether to restore an object's original state on rollback.booleanWhether objects retain their persistent state on transaction commit.Deprecated.useOpenJPAEntityTransaction.getRollbackCause()instead:em.getTransaction().getRollbackCause()booleanDeprecated.useEntityTransaction.getRollbackOnly()instead:em.getTransaction().getRollbackOnly()Get the properties supported by this runtime.booleanWhether to check for a global transaction upon every managed, non-transactional operation.Return a set of current transaction instances.intDeprecated.cast toOpenJPAEntityManagerSPIinstead.Return the set of classes for objects that have been modified in the current transaction.getUserObject(Object key) Get the value for the specified key from the map of user objects.getVersion(Object o) Returns the current version indicator foro.booleanisActive()Deprecated.useEntityTransaction.isActive()instead:em.getTransaction().isActive()booleanisDetached(Object o) Returnstrueifpcis a detached object (one that can be reattached to aEntityManagervia a call toEntityManager.merge(T)); otherwise returnsfalse.booleanReturn whether the given object is dirty.booleanDeprecated.useisTrackChangesByType()instead.booleanDeprecated.useisTransactionManaged()instead to interrogate whether or not this EntityManager's transaction is managed.booleanReturn whether the given object was made persistent in the current transaction.booleanReturn whether the given object is persistent.booleanReturn whether the given object is deleted.booleanWhether a store transaction is active.booleanWhether memory usage is reduced during this transaction at the expense of tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.booleanReturn whether the given object is transactional.booleanWhether this entity manager is using managed transactions.voidEnsure that the given instance is locked at the current lock level, as set in theFetchPlanfor the entity manager.voidEnsure that the given instance is locked at the given lock level.voidEnsure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.voidEnsure that the given instances are locked at the given lock level.voidlockAll(Collection pcs) Ensure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.voidlockAll(Collection pcs, jakarta.persistence.LockModeType mode, int timeout) Ensure that the given instances are locked at the given lock level.Object[]Merge the specified objects into the entity manager.mergeAll(Collection pcs) Merge the specified detached objects into the entity manager.voidMake the given object nontransactional.voidnontransactionalAll(Object[] objs) Make the given objects nontransactional.voidMake the given objects nontransactional.voidpersistAll(Object... pcs) Persist the given objects.voidpersistAll(Collection pcs) Persist the given objects.voidPops the fetch plan from the top of the stack, making the next one down the active one.voidpreFlush()Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks.Pushes a new fetch plan that inherits from the current fetch plan onto a stack, and makes the new plan the active one.putUserObject(Object key, Object val) Put the specified key-value pair into the map of user objects.voidRefresh all transactional objects.voidrefreshAll(Object... pcs) Refresh the state of the given objects.voidrefreshAll(Collection pcs) Refresh the state of the given objects.voidRelease the given object from management.voidreleaseAll(Object... pcs) Release the given object from management.voidreleaseAll(Collection pcs) Release the given objects from management.voidRelease the last set savepoint and any resources associated with it.voidreleaseSavepoint(String name) Release the savepoint and any resources associated with it.voidDelete the given persistent objects.voidremoveAll(Collection pcs) Delete the given persistent objects.voidremoveLifecycleListener(Object listener) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidremoveTransactionListener(Object listener) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidImmediately load the given object's persistent fields.voidretrieveAll(Object... pcs) Retrieve the persistent state of the given objects.voidretrieveAll(Collection pcs) Retrieve the persistent state of the given objects.voidrollback()Deprecated.useEntityTransaction.rollback()instead:em.getTransaction().rollback()voidDeprecated.useOpenJPAEntityTransaction.rollbackAndResume()instead:em.getTransaction().rollbackAndResume()voidRollback the current transaction to the last savepoint.voidrollbackToSavepoint(String name) Rollback the current transaction to the given savepoint name.voidsetAutoClear(int autoClear) Deprecated.usesetAutoClear(AutoClearType)instead.voidsetAutoClear(AutoClearType clearType) Whether to clear state when entering a transaction.voidsetAutoDetach(int autoDetachFlags) Deprecated.usesetAutoDetach(AutoDetachType)orsetAutoDetach(java.util.EnumSet)instead.voidsetAutoDetach(int flag, boolean on) Deprecated.usesetAutoDetach(AutoDetachType, boolean)instead.voidsetAutoDetach(EnumSet<AutoDetachType> values) AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.voidsetAutoDetach(AutoDetachType value) AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.voidsetAutoDetach(AutoDetachType value, boolean on) Bit flags marked inAutoDetachTypewhich indicate when persistent managed objects should be automatically detached in-place.voidsetDetachState(int detach) Deprecated.usesetDetachState(DetachStateType)instead.voidDetach mode constant to determine which fields are part of the detached graph.voidsetEvictFromStoreCache(boolean evict) Whether to also evict an object from the store cache when it is evicted through this entity manager.voidsetIgnoreChanges(boolean ignore) Whether to take into account changes in the transaction when executing a query or iterating an extent.voidsetLargeTransaction(boolean value) Deprecated.usesetTrackChangesByType(boolean)instead.voidsetLifecycleListenerCallbackMode(int callbackMode) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidsetMultithreaded(boolean multi) Whether the entity manager or its managed instances are used in a multithreaded environment.voidsetNontransactionalRead(boolean read) Whether to allow nontransactional access to persistent state.voidsetNontransactionalWrite(boolean write) Whether to allow nontransactional changes to persistent state.voidsetOptimistic(boolean opt) Whether to use optimistic transactional semantics.voidsetOrderDirtyObjects(boolean order) Whether dirty objects will be returned in the order they were dirtied.voidsetPopulateStoreCache(boolean cache) Whether to populate the store cache with objects used by this transaction.voidsetRestoreState(int restore) Deprecated.usesetRestoreState(RestoreStateType)instead.voidsetRestoreState(RestoreStateType restoreType) Whether to restore an object's original state on rollback.voidsetRetainState(boolean retain) Whether objects retain their persistent state on transaction commit.voidDeprecated.useEntityTransaction.setRollbackOnly()instead:em.getTransaction().setRollbackOnly()voidsetRollbackOnly(Throwable cause) Deprecated.useOpenJPAEntityTransaction.setRollbackOnly(java.lang.Throwable)instead:em.getTransaction().setRollbackOnly()voidsetSavepoint(String name) Set a transactional savepoint where operations after this savepoint will be rolled back.voidsetSyncWithManagedTransactions(boolean resync) Whether to check for a global transaction upon every managed, non-transactional operation.voidsetTrackChangesByType(boolean track) If a large number of objects will be created, modified, or deleted during this transaction setting this option to true will reduce memory usage if you perform periodic flushes by tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.voidsetTransactionListenerCallbackMode(int callbackMode) Deprecated.cast toOpenJPAEntityManagerSPIinstead.voidtransactional(Object pc, boolean updateVersion) Make the given object transactional.voidtransactionalAll(Object[] objs, boolean updateVersion) Make the given objects transactional.voidtransactionalAll(Collection objs, boolean updateVersion) Make the given objects transactional.voidValidate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc.Methods inherited from interface jakarta.persistence.EntityManager
clear, close, contains, createEntityGraph, createEntityGraph, createNamedQuery, createNamedStoredProcedureQuery, createQuery, createQuery, createQuery, createQuery, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, detach, find, find, find, find, flush, getDelegate, getEntityGraph, getEntityGraphs, getFlushMode, getMetamodel, getProperties, getReference, isJoinedToTransaction, isOpen, joinTransaction, lock, lock, merge, persist, refresh, refresh, refresh, refresh, remove, setFlushMode, setProperty, unwrap
-
Field Details
-
CONN_RETAIN_DEMAND
Deprecated.use theConnectionRetainModeenum instead.- See Also:
-
CONN_RETAIN_TRANS
Deprecated.use theConnectionRetainModeenum instead.- See Also:
-
CONN_RETAIN_ALWAYS
Deprecated.use theConnectionRetainModeenum instead.- See Also:
-
DETACH_FETCH_GROUPS
Deprecated.use theDetachStateTypeenum instead.- See Also:
-
DETACH_FGS
Deprecated.use theDetachStateTypeenum instead.- See Also:
-
DETACH_LOADED
Deprecated.use theDetachStateTypeenum instead.- See Also:
-
DETACH_ALL
Deprecated.use theDetachStateTypeenum instead.- See Also:
-
RESTORE_NONE
Deprecated.use theRestoreStateTypeenum instead.- See Also:
-
RESTORE_IMMUTABLE
Deprecated.use theRestoreStateTypeenum instead.- See Also:
-
RESTORE_ALL
Deprecated.use theRestoreStateTypeenum instead.- See Also:
-
DETACH_CLOSE
Deprecated.use theAutoDetachTypeenum instead.- See Also:
-
DETACH_COMMIT
Deprecated.use theAutoDetachTypeenum instead.- See Also:
-
DETACH_NONTXREAD
Deprecated.use theAutoDetachTypeenum instead.- See Also:
-
DETACH_ROLLBACK
Deprecated.use theAutoDetachTypeenum instead.- See Also:
-
CLEAR_DATASTORE
Deprecated.use theAutoClearTypeenum instead.- See Also:
-
CLEAR_ALL
Deprecated.use theAutoClearTypeenum instead.- See Also:
-
CALLBACK_FAIL_FAST
Deprecated.use theCallbackModeenum instead.- See Also:
-
CALLBACK_IGNORE
Deprecated.use theCallbackModeenum instead.- See Also:
-
CALLBACK_LOG
Deprecated.use theCallbackModeenum instead.- See Also:
-
CALLBACK_RETHROW
Deprecated.use theCallbackModeenum instead.- See Also:
-
CALLBACK_ROLLBACK
Deprecated.use theCallbackModeenum instead.- See Also:
-
-
Method Details
-
getEntityManagerFactory
OpenJPAEntityManagerFactory getEntityManagerFactory()Return the factory that produced this entity manager.- Specified by:
getEntityManagerFactoryin interfacejakarta.persistence.EntityManager
-
getFetchPlan
FetchPlan getFetchPlan()Return the (mutable) fetch plan for loading objects from this entity manager. -
pushFetchPlan
FetchPlan pushFetchPlan()Pushes a new fetch plan that inherits from the current fetch plan onto a stack, and makes the new plan the active one.- Returns:
- the new fetch plan
- Since:
- 1.1.0
-
popFetchPlan
void popFetchPlan()Pops the fetch plan from the top of the stack, making the next one down the active one. This returns void to avoid confusion, since fetch plans tend to be used in method-chaining patterns often.- Since:
- 1.1.0
-
getConnectionRetainMode
ConnectionRetainMode getConnectionRetainMode()Return the connection retain mode for this entity manager. -
isTransactionManaged
boolean isTransactionManaged()Whether this entity manager is using managed transactions.- Since:
- 1.1.0
-
isManaged
Deprecated.useisTransactionManaged()instead to interrogate whether or not this EntityManager's transaction is managed. To determine if a given entity instance is managed, useEntityManager.contains(java.lang.Object). -
getSyncWithManagedTransactions
boolean getSyncWithManagedTransactions()Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false. -
setSyncWithManagedTransactions
void setSyncWithManagedTransactions(boolean resync) Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false. -
getClassLoader
ClassLoader getClassLoader()Return the current thread's class loader at the time this entity manager was obtained from the factory. -
getConnectionUserName
String getConnectionUserName()Return the connection user name. -
getConnectionPassword
String getConnectionPassword()Return the connection password. -
getMultithreaded
boolean getMultithreaded()Whether the entity manager or its managed instances are used in a multithreaded environment. -
setMultithreaded
void setMultithreaded(boolean multi) Whether the entity manager or its managed instances are used in a multithreaded environment. -
getIgnoreChanges
boolean getIgnoreChanges()Whether to take into account changes in the transaction when executing a query or iterating an extent. -
setIgnoreChanges
void setIgnoreChanges(boolean ignore) Whether to take into account changes in the transaction when executing a query or iterating an extent. -
getNontransactionalRead
boolean getNontransactionalRead()Whether to allow nontransactional access to persistent state. -
setNontransactionalRead
void setNontransactionalRead(boolean read) Whether to allow nontransactional access to persistent state. -
getNontransactionalWrite
boolean getNontransactionalWrite()Whether to allow nontransactional changes to persistent state. -
setNontransactionalWrite
void setNontransactionalWrite(boolean write) Whether to allow nontransactional changes to persistent state. -
getOptimistic
boolean getOptimistic()Whether to use optimistic transactional semantics. -
setOptimistic
void setOptimistic(boolean opt) Whether to use optimistic transactional semantics. -
getRestoreState
RestoreStateType getRestoreState()Whether to restore an object's original state on rollback. -
setRestoreState
Whether to restore an object's original state on rollback. -
getRetainState
boolean getRetainState()Whether objects retain their persistent state on transaction commit. -
setRetainState
void setRetainState(boolean retain) Whether objects retain their persistent state on transaction commit. -
getDetachState
DetachStateType getDetachState()Detach mode constant to determine which fields are part of the detached graph. -
setDetachState
Detach mode constant to determine which fields are part of the detached graph. -
getAutoClear
AutoClearType getAutoClear()Whether to clear state when entering a transaction. -
setAutoClear
Whether to clear state when entering a transaction. -
getAutoDetach
EnumSet<AutoDetachType> getAutoDetach()AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place. -
setAutoDetach
AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place. The current value is replaced in its entirety. -
setAutoDetach
AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place. The current value is replaced in its entirety. -
setAutoDetach
Bit flags marked inAutoDetachTypewhich indicate when persistent managed objects should be automatically detached in-place.- Since:
- 1.1.0
-
getEvictFromStoreCache
boolean getEvictFromStoreCache()Whether to also evict an object from the store cache when it is evicted through this entity manager. -
setEvictFromStoreCache
void setEvictFromStoreCache(boolean evict) Whether to also evict an object from the store cache when it is evicted through this entity manager. -
getPopulateStoreCache
boolean getPopulateStoreCache()Whether objects accessed during this transaction will be added to the store cache. Defaults to true.- Since:
- 0.3.4
-
setPopulateStoreCache
void setPopulateStoreCache(boolean cache) Whether to populate the store cache with objects used by this transaction. Defaults to true.- Since:
- 0.3.4
-
isTrackChangesByType
boolean isTrackChangesByType()Whether memory usage is reduced during this transaction at the expense of tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.- Since:
- 1.0.0
-
setTrackChangesByType
void setTrackChangesByType(boolean track) If a large number of objects will be created, modified, or deleted during this transaction setting this option to true will reduce memory usage if you perform periodic flushes by tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.- Since:
- 1.0.0
-
putUserObject
Put the specified key-value pair into the map of user objects. Use a value of null to remove the key. -
getUserObject
Get the value for the specified key from the map of user objects. -
findAll
Return the objects with the given oids.- Parameters:
oids- the oids of the objects to return- Returns:
- the objects that were looked up, in the same order as the oids parameter.
- See Also:
-
EntityManager.find(Class,Object)
-
findAll
Return the objects with the given oids.- Parameters:
oids- the oids of the objects to return- Returns:
- the objects that were looked up, in the same order as the oids parameter.
- See Also:
-
EntityManager.find(Class,Object)
-
findCached
Return the cached instance for the given oid/object, or null if not cached.- Parameters:
oid- the object's id- Returns:
- the cached object, or null if not cached
-
getObjectIdClass
Return the application identity class the given persistent class uses for object ids, or null if not a type that uses application identity. -
getTransaction
OpenJPAEntityTransaction getTransaction()- Specified by:
getTransactionin interfacejakarta.persistence.EntityManager
-
setSavepoint
Set a transactional savepoint where operations after this savepoint will be rolled back. -
rollbackToSavepoint
void rollbackToSavepoint()Rollback the current transaction to the last savepoint. Savepoints set after this one will become invalid. -
rollbackToSavepoint
Rollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid. -
releaseSavepoint
void releaseSavepoint()Release the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid. -
releaseSavepoint
Release the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid. -
preFlush
void preFlush()Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks. Transaction listeners are not invoked.- Since:
- 0.3.3
-
validateChanges
void validateChanges()Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc. In a datastore transaction or a flushed optimistic transaction, this method will act just likeEntityManager.flush(). In an optimistic transaction that has not yet begun a datastore-level transaction, however, it will only report exceptions that would occur on flush, without retaining any datastore resources. -
isStoreActive
boolean isStoreActive()Whether a store transaction is active. -
beginStore
void beginStore()Begins a store transaction if one isn't already started. The entity manager must already be in a logical transaction. -
containsAll
Whether the given objects are managed. -
containsAll
Whether the given objects are managed. -
persistAll
Persist the given objects. -
persistAll
Persist the given objects. -
removeAll
Delete the given persistent objects. -
removeAll
Delete the given persistent objects. -
release
Release the given object from management. This operation is not recursive. -
releaseAll
Release the given object from management. This operation is not recursive. -
releaseAll
Release the given objects from management. This operation is not recursive. -
retrieve
Immediately load the given object's persistent fields. One might use this action to make sure that an instance's fields are loaded before transitioning it to transient. Note that this action is not recursive. Any related objects that are loaded will not necessarily have their fields loaded. -
retrieveAll
Retrieve the persistent state of the given objects.- See Also:
-
retrieveAll
Retrieve the persistent state of the given objects.- See Also:
-
refreshAll
Refresh the state of the given objects. -
refreshAll
Refresh the state of the given objects. -
refreshAll
void refreshAll()Refresh all transactional objects. -
evict
Evict the given object.
Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
- Parameters:
pc- A persistent class which will be evicted
-
evictAll
Evict the given objects.
Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
- Parameters:
pcs- The persistent classes which will be evicted
-
evictAll
Evict the given objects.
Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
- Parameters:
pcs- A collection of persistent classes which will be evicted.
-
evictAll
void evictAll()Evict all clean objects.
Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
-
evictAll
Evict all persistent-clean and persistent-nontransactional instances in the extent of the given class (including subclasses).
Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
- Parameters:
cls- All clean instances of this class will be evicted.
-
evictAll
Evict all persistent-clean and persistent-nontransactional instances in the given
Extent.Eviction acts as a hint to the persistence provider, and indicates that the persistent object is no longer needed by the application and may be garbage collected. It does not remove the object from the L1 cache and only affects objects which are managed and unmodified.
- Parameters:
extent- Extend which contains the persistent classes to evict.
-
detachCopy
<T> T detachCopy(T pc) Detach the specified object from the entity manager, detaching based on the AutoDetach value specified and returning a copy of the detached entity.- Parameters:
pc- the instance to detach- Returns:
- the detached instance
- Since:
- 2.0.0
Note: This method provides the same contract as the detach method with
signature: public
T detach(T pc) available in the 1.x release of OpenJPA. The JPA 2.0 specification defined a method with an incompatible signature and different semantics. The specification defined method trumped the existing method.
-
detachAll
Detach the specified objects from the entity manager.- Parameters:
pcs- the instances to detach- Returns:
- the detached instances
-
detachAll
Detach the specified objects from the entity manager.- Parameters:
pcs- the instances to detach- Returns:
- the detached instances
-
mergeAll
Merge the specified objects into the entity manager.- Parameters:
pcs- instances to import- Returns:
- the re-attached instances
-
mergeAll
Merge the specified detached objects into the entity manager.- Parameters:
pcs- Collection of instances to import- Returns:
- the re-attached instances
-
transactional
Make the given object transactional.- Parameters:
pc- instance to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
transactionalAll
Make the given objects transactional.- Parameters:
objs- instances to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
transactionalAll
Make the given objects transactional.- Parameters:
objs- instances to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
nontransactional
Make the given object nontransactional. -
nontransactionalAll
Make the given objects nontransactional. -
nontransactionalAll
Make the given objects nontransactional. -
getNamedGenerator
Return the named generator defined in the metadata. -
getIdGenerator
Returns aGeneratorfor the datastore identity values of the specified type, or null if the type is unmanaged or its identity cannot be represented by a sequence. -
getFieldGenerator
Returns aGeneratorfor the generated values of the specified type, or null if the field is not generated. -
createExtent
Return an extent of the given class, optionally including subclasses. -
createQuery
- Specified by:
createQueryin interfacejakarta.persistence.EntityManager
-
createNamedQuery
- Specified by:
createNamedQueryin interfacejakarta.persistence.EntityManager
-
createNativeQuery
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager
-
createNativeQuery
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager
-
createNativeQuery
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager
-
createQuery
Create a new query from the given one. -
createQuery
Create a new query in the given language. -
createDynamicQuery
Create an executable query from a dynamically defined query.- Since:
- 2.0.0
-
getLockMode
Return the lock mode of the given instance, or null if not locked.- Specified by:
getLockModein interfacejakarta.persistence.EntityManager
-
lock
Ensure that the given instance is locked at the given lock level.- Parameters:
pc- the object to lockmode- the lock level to usetimeout- the number of milliseconds to wait for the lock before giving up, or -1 for no limit
-
lock
Ensure that the given instance is locked at the current lock level, as set in theFetchPlanfor the entity manager. -
lockAll
Ensure that the given instances are locked at the given lock level.- Parameters:
pcs- the objects to lockmode- the lock level to usetimeout- the number of milliseconds to wait for the lock before giving up, or -1 for no limit
-
lockAll
Ensure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager. -
lockAll
Ensure that the given instances are locked at the given lock level.- Parameters:
pcs- the objects to lockmode- the lock level to usetimeout- the number of milliseconds to wait for the lock before giving up, or -1 for no limit
-
lockAll
Ensure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager. -
cancelAll
boolean cancelAll()Cancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set.- Returns:
- true if any statements were cancelled, false otherwise
-
getConnection
Object getConnection()Return the connection in use by the entity manager, or a new connection if none. -
getManagedObjects
Collection getManagedObjects()Return a set of all managed instances. -
getTransactionalObjects
Collection getTransactionalObjects()Return a set of current transaction instances. -
getPendingTransactionalObjects
Collection getPendingTransactionalObjects()Return a set of instances which will become transactional upon the next transaction. -
getDirtyObjects
Collection getDirtyObjects()Return a set of current dirty instances. -
getOrderDirtyObjects
boolean getOrderDirtyObjects()Whether dirty objects will be returned in the order they were dirtied. Default is determined by the store manager. -
setOrderDirtyObjects
void setOrderDirtyObjects(boolean order) Whether dirty objects will be returned in the order they were dirtied. Default is determined by the store manager. -
dirtyClass
Mark the given class as dirty within the current transaction. -
getPersistedClasses
Collection<Class> getPersistedClasses()Return the set of classes that have been made persistent in the current transaction. -
getRemovedClasses
Collection<Class> getRemovedClasses()Return the set of classes that have been deleted in the current transaction. -
getUpdatedClasses
Collection<Class> getUpdatedClasses()Return the set of classes for objects that have been modified in the current transaction. -
createInstance
Create a new instance of typecls. Ifclsis an interface or an abstract class whose abstract methods follow the JavaBeans convention, this method will create a concrete implementation according to the metadata that defines the class. Ifclsis a non-final concrete type that has metadata but does not implementPersistenceCapable, this method will create a subclass of the type that does implementPersistenceCapable, and will attempt to redefine the methods inclsto enable persistent attribute tracking. Otherwise, ifclsis a managed type, this will return an instance of the specified class.- Throws:
IllegalArgumentException- ifclsis not a managed type or interface.
-
dirty
Make the named field of the given object dirty. -
getObjectId
Return the oid of the given instance. -
isDirty
Return whether the given object is dirty. -
isTransactional
Return whether the given object is transactional. -
isPersistent
Return whether the given object is persistent. -
isNewlyPersistent
Return whether the given object was made persistent in the current transaction. -
isRemoved
Return whether the given object is deleted. -
isDetached
Returnstrueifpcis a detached object (one that can be reattached to aEntityManagervia a call toEntityManager.merge(T)); otherwise returnsfalse. -
getVersion
Returns the current version indicator foro. -
getConfiguration
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
setRestoreState
Deprecated.usesetRestoreState(RestoreStateType)instead. -
setDetachState
Deprecated.usesetDetachState(DetachStateType)instead. -
setAutoClear
Deprecated.usesetAutoClear(AutoClearType)instead. -
setAutoDetach
Deprecated.usesetAutoDetach(AutoDetachType)orsetAutoDetach(java.util.EnumSet)instead. -
setAutoDetach
Deprecated.usesetAutoDetach(AutoDetachType, boolean)instead. -
isLargeTransaction
Deprecated.useisTrackChangesByType()instead. -
setLargeTransaction
Deprecated.usesetTrackChangesByType(boolean)instead. -
addTransactionListener
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
removeTransactionListener
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
getTransactionListenerCallbackMode
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
setTransactionListenerCallbackMode
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
addLifecycleListener
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
removeLifecycleListener
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
getLifecycleListenerCallbackMode
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
setLifecycleListenerCallbackMode
Deprecated.cast toOpenJPAEntityManagerSPIinstead. This method pierces the published-API boundary, as does the SPI cast. -
begin
Deprecated.useEntityTransaction.begin()instead:em.getTransaction().begin()- Specified by:
beginin interfacejakarta.persistence.EntityTransaction
-
commit
Deprecated.useEntityTransaction.commit()instead:em.getTransaction().commit()- Specified by:
commitin interfacejakarta.persistence.EntityTransaction
-
rollback
Deprecated.useEntityTransaction.rollback()instead:em.getTransaction().rollback()- Specified by:
rollbackin interfacejakarta.persistence.EntityTransaction
-
isActive
Deprecated.useEntityTransaction.isActive()instead:em.getTransaction().isActive()- Specified by:
isActivein interfacejakarta.persistence.EntityTransaction
-
commitAndResume
Deprecated.useOpenJPAEntityTransaction.commitAndResume()instead:em.getTransaction().commitAndResume() -
rollbackAndResume
Deprecated.useOpenJPAEntityTransaction.rollbackAndResume()instead:em.getTransaction().rollbackAndResume() -
setRollbackOnly
Deprecated.useEntityTransaction.setRollbackOnly()instead:em.getTransaction().setRollbackOnly()- Specified by:
setRollbackOnlyin interfacejakarta.persistence.EntityTransaction
-
setRollbackOnly
Deprecated.useOpenJPAEntityTransaction.setRollbackOnly(java.lang.Throwable)instead:em.getTransaction().setRollbackOnly() -
getRollbackCause
Deprecated.useOpenJPAEntityTransaction.getRollbackCause()instead:em.getTransaction().getRollbackCause() -
getRollbackOnly
Deprecated.useEntityTransaction.getRollbackOnly()instead:em.getTransaction().getRollbackOnly()- Specified by:
getRollbackOnlyin interfacejakarta.persistence.EntityTransaction
-
getCriteriaBuilder
OpenJPACriteriaBuilder getCriteriaBuilder()Gets the QueryBuilder with OpenJPA-extended capabilities.- Specified by:
getCriteriaBuilderin interfacejakarta.persistence.EntityManager- Since:
- 2.0.0
-
getSupportedProperties
Get the properties supported by this runtime.- Since:
- 2.0.0
-
CallbackModeenum instead.