Class EntityManagerImpl
- java.lang.Object
-
- org.apache.openjpa.persistence.EntityManagerImpl
-
- All Implemented Interfaces:
jakarta.persistence.EntityManager,jakarta.persistence.EntityTransaction,Externalizable,Serializable,AutoCloseable,FindCallbacks,OpCallbacks,Closeable,OpenJPAEntityManager,OpenJPAEntityManagerSPI,OpenJPAEntityTransaction
public class EntityManagerImpl extends Object implements OpenJPAEntityManagerSPI, Externalizable, FindCallbacks, OpCallbacks, Closeable, OpenJPAEntityTransaction
Implementation ofEntityManagerinterface.- Author:
- Patrick Linskey, Abe White
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected RuntimeExceptionTranslator_ret-
Fields inherited from interface org.apache.openjpa.kernel.OpCallbacks
ACT_CASCADE, ACT_NONE, ACT_RUN, OP_ATTACH, OP_DELETE, OP_DETACH, OP_EVICT, OP_LOCK, OP_NONTRANSACTIONAL, OP_PERSIST, OP_REFRESH, OP_RELEASE, OP_RETRIEVE, OP_TRANSACTIONAL
-
Fields inherited from interface org.apache.openjpa.persistence.OpenJPAEntityManager
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK, CLEAR_ALL, CLEAR_DATASTORE, CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS, DETACH_ALL, DETACH_CLOSE, DETACH_COMMIT, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADED, DETACH_NONTXREAD, DETACH_ROLLBACK, RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONE
-
-
Constructor Summary
Constructors Constructor Description EntityManagerImpl()EntityManagerImpl(EntityManagerFactoryImpl factory, Broker broker)Constructor; supply factory and delegate.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddLifecycleListener(Object listener, Class... classes)Register a listener for lifecycle-related events on the specified classes.voidaddTransactionListener(Object listener)Register a listener for transaction-related events.protected voidassertNotCloseInvoked()Throw appropriate exception if close has been invoked but the broker is still open.voidbegin()voidbeginStore()Begins a store transaction if one isn't already started.booleancancelAll()Cancel all pending data store statements.voidclear()voidclose()voidcommit()voidcommitAndResume()Issue a commit and then start a new transaction.booleancontains(Object entity)booleancontainsAll(Object... entities)Whether the given objects are managed.booleancontainsAll(Collection entities)Whether the given objects are managed.OpenJPAQuerycreateDynamicQuery(QueryDefinition qdef)Create an executable query from a dynamically defined query.<T> jakarta.persistence.EntityGraph<T>createEntityGraph(Class<T> rootType)jakarta.persistence.EntityGraph<?>createEntityGraph(String graphName)<T> Extent<T>createExtent(Class<T> cls, boolean subclasses)Return an extent of the given class, optionally including subclasses.<T> TcreateInstance(Class<T> cls)Create a new instance of typecls.OpenJPAQuerycreateNamedQuery(String name)<T> jakarta.persistence.TypedQuery<T>createNamedQuery(String name, Class<T> resultClass)jakarta.persistence.StoredProcedureQuerycreateNamedStoredProcedureQuery(String name)OpenJPAQuerycreateNativeQuery(String query)OpenJPAQuerycreateNativeQuery(String query, Class cls)OpenJPAQuerycreateNativeQuery(String query, String mappingName)jakarta.persistence.QuerycreateQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)<T> jakarta.persistence.TypedQuery<T>createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)Create a query from the given CritriaQuery.jakarta.persistence.QuerycreateQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)OpenJPAQuerycreateQuery(jakarta.persistence.Query query)Create a new query from the given one.OpenJPAQuerycreateQuery(String query)<T> jakarta.persistence.TypedQuery<T>createQuery(String query, Class<T> resultClass)OpenJPAQuerycreateQuery(String language, String query)Create a new query in the given language.jakarta.persistence.StoredProcedureQuerycreateStoredProcedureQuery(String procedureName)jakarta.persistence.StoredProcedureQuerycreateStoredProcedureQuery(String procedureName, Class... resultClasses)jakarta.persistence.StoredProcedureQuerycreateStoredProcedureQuery(String procedureName, String... resultSetMappings)voiddetach(Object entity)Object[]detachAll(Object... entities)Detach the specified objects from the entity manager.CollectiondetachAll(Collection entities)Detach the specified objects from the entity manager.<T> TdetachCopy(T entity)Detach the specified object from the entity manager, detaching based on the AutoDetach value specified and returning a copy of the detached entity.voiddirty(Object o, String field)Make the named field of the given object dirty.voiddirtyClass(Class cls)Mark the given class as dirty within the current transaction.booleanequals(Object other)voidevict(Object entity)Evict the given object.voidevictAll()Evict all clean objects.voidevictAll(Class cls)Evict all persistent-clean and persistent-nontransactional instances in the extent of the given class (including subclasses).voidevictAll(Object... entities)Evict the given objects.voidevictAll(Collection entities)Evict the given objects.voidevictAll(Extent extent)Evict all persistent-clean and persistent-nontransactional instances in the givenExtent.<T> Tfind(Class<T> cls, Object oid)<T> Tfind(Class<T> cls, Object oid, jakarta.persistence.LockModeType mode)<T> Tfind(Class<T> cls, Object oid, jakarta.persistence.LockModeType mode, Map<String,Object> properties)<T> Tfind(Class<T> cls, Object oid, Map<String,Object> properties)<T> T[]findAll(Class<T> cls, Object... oids)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.voidflush()AutoClearTypegetAutoClear()Whether to clear state when entering a transaction.EnumSet<AutoDetachType>getAutoDetach()AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.BrokergetBroker()Broker delegate.ClassLoadergetClassLoader()Return the current thread's class loader at the time this entity manager was obtained from the factory.OpenJPAConfigurationgetConfiguration()Return the configuration associated with this entity manager.ObjectgetConnection()Return the connection in use by the entity manager, or a new connection if none.StringgetConnectionPassword()Return the connection password.ConnectionRetainModegetConnectionRetainMode()Return the connection retain mode for this entity manager.StringgetConnectionUserName()Return the connection user name.OpenJPACriteriaBuildergetCriteriaBuilder()Gets the QueryBuilder with OpenJPA-extended capabilities.ObjectgetDelegate()DetachStateTypegetDetachState()Detach mode constant to determine which fields are part of the detached graph.CollectiongetDirtyObjects()Return a set of current dirty instances.jakarta.persistence.EntityGraph<?>getEntityGraph(String graphName)<T> List<jakarta.persistence.EntityGraph<? super T>>getEntityGraphs(Class<T> entityClass)OpenJPAEntityManagerFactorygetEntityManagerFactory()Return the factory that produced this entity manager.booleangetEvictFromStoreCache()Whether to also evict an object from the store cache when it is evicted through this entity manager.FetchPlangetFetchPlan()Return the (mutable) fetch plan for loading objects from this entity manager.GeneratorgetFieldGenerator(Class forClass, String fieldName)Returns aGeneratorfor the generated values of the specified type, or null if the field is not generated.jakarta.persistence.FlushModeTypegetFlushMode()GeneratorgetIdGenerator(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.booleangetIgnoreChanges()Whether to take into account changes in the transaction when executing a query or iterating an extent.intgetLifecycleListenerCallbackMode()EnumSet<CallbackMode>getLifecycleListenerCallbackModes()TheCallbackModeflags for handling lifecycle listener exceptions.jakarta.persistence.LockModeTypegetLockMode(Object entity)Return the lock mode of the given instance, or null if not locked.CollectiongetManagedObjects()Return a set of all managed instances.ManagedRuntimegetManagedRuntime()Return the managed runtime in use.jakarta.persistence.metamodel.MetamodelgetMetamodel()booleangetMultithreaded()Whether the entity manager or its managed instances are used in a multithreaded environment.GeneratorgetNamedGenerator(String name)Return the named generator defined in the metadata.booleangetNontransactionalRead()Whether to allow nontransactional access to persistent state.booleangetNontransactionalWrite()Whether to allow nontransactional changes to persistent state.ObjectgetObjectId(Object o)Return the oid of the given instance.ClassgetObjectIdClass(Class cls)Return the application identity class the given persistent class uses for object ids, or null if not a type that uses application identity.booleangetOptimistic()Whether to use optimistic transactional semantics.booleangetOrderDirtyObjects()Whether dirty objects will be returned in the order they were dirtied.CollectiongetPendingTransactionalObjects()Return a set of instances which will become transactional upon the next transaction.Collection<Class>getPersistedClasses()Return the set of classes that have been made persistent in the current transaction.booleangetPopulateStoreCache()Whether objects accessed during this transaction will be added to the store cache.Map<String,Object>getProperties()Get the properties used currently by this entity manager.booleangetQuerySQLCache()Affirms if this receiver is caching database queries.<T> TgetReference(Class<T> cls, Object oid)Collection<Class>getRemovedClasses()Return the set of classes that have been deleted in the current transaction.RestoreStateTypegetRestoreState()Whether to restore an object's original state on rollback.booleangetRetainState()Whether objects retain their persistent state on transaction commit.ThrowablegetRollbackCause()Returns the Throwable that caused the transaction to be marked for rollback.booleangetRollbackOnly()Set<String>getSupportedProperties()Get the properties supported by this runtime.booleangetSyncWithManagedTransactions()Whether to check for a global transaction upon every managed, non-transactional operation.OpenJPAEntityTransactiongetTransaction()CollectiongetTransactionalObjects()Return a set of current transaction instances.intgetTransactionListenerCallbackMode()EnumSet<CallbackMode>getTransactionListenerCallbackModes()TheCallbackModeflags for handling transaction listener exceptions.Collection<Class>getUpdatedClasses()Return the set of classes for objects that have been modified in the current transaction.ObjectgetUserObject(Object key)Get the value for the specified key from the map of user objects.ObjectgetVersion(Object o)Returns the current version indicator foro.inthashCode()booleanisActive()booleanisDetached(Object entity)Returnstrueifpcis a detached object (one that can be reattached to aEntityManagervia a call toEntityManager.merge(T)); otherwise returnsfalse.booleanisDirty(Object o)Return whether the given object is dirty.booleanisJoinedToTransaction()booleanisLargeTransaction()booleanisManaged()booleanisNewlyPersistent(Object o)Return whether the given object was made persistent in the current transaction.booleanisOpen()booleanisPersistent(Object o)Return whether the given object is persistent.booleanisRemoved(Object o)Return whether the given object is deleted.booleanisStoreActive()Whether a store transaction is active.booleanisTrackChangesByType()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.booleanisTransactional(Object o)Return whether the given object is transactional.booleanisTransactionManaged()Whether this entity manager is using managed transactions.voidjoinTransaction()voidlock(Object entity)Ensure that the given instance is locked at the current lock level, as set in theFetchPlanfor the entity manager.voidlock(Object entity, jakarta.persistence.LockModeType mode)voidlock(Object entity, jakarta.persistence.LockModeType mode, int timeout)Ensure that the given instance is locked at the given lock level.voidlock(Object entity, jakarta.persistence.LockModeType mode, Map<String,Object> properties)voidlockAll(Object... entities)Ensure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.voidlockAll(Object[] entities, jakarta.persistence.LockModeType mode, int timeout)Ensure that the given instances are locked at the given lock level.voidlockAll(Collection entities)Ensure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.voidlockAll(Collection entities, jakarta.persistence.LockModeType mode, int timeout)Ensure that the given instances are locked at the given lock level.<T> Tmerge(T entity)Object[]mergeAll(Object... entities)Merge the specified objects into the entity manager.CollectionmergeAll(Collection entities)Merge the specified detached objects into the entity manager.protected <T> QueryImpl<T>newQueryImpl(Query kernelQuery)protected <T> QueryImpl<T>newQueryImpl(Query kernelQuery, QueryMetaData qmd)voidnontransactional(Object entity)Make the given object nontransactional.voidnontransactionalAll(Object[] objs)Make the given objects nontransactional.voidnontransactionalAll(Collection objs)Make the given objects nontransactional.voidpersist(Object entity)voidpersistAll(Object... entities)Persist the given objects.voidpersistAll(Collection entities)Persist the given objects.voidpopFetchPlan()Pops 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.voidprepareForPooling()Deprecated.- useclear()instead.intprocessArgument(int op, Object obj, OpenJPAStateManager sm)Process operation argument.ObjectprocessArgument(Object arg)Process find argument.ObjectprocessReturn(Object oid, OpenJPAStateManager sm)Process operation return value.FetchPlanpushFetchPlan()Pushes a new fetch plan that inherits from the current fetch plan onto a stack, and makes the new plan the active one.FetchPlanpushFetchPlan(FetchConfiguration fc)ObjectputUserObject(Object key, Object val)Put the specified key-value pair into the map of user objects.voidreadExternal(ObjectInput in)voidrefresh(Object entity)voidrefresh(Object entity, jakarta.persistence.LockModeType mode)voidrefresh(Object entity, jakarta.persistence.LockModeType mode, Map<String,Object> properties)voidrefresh(Object entity, Map<String,Object> properties)voidrefreshAll()Refresh all transactional objects.voidrefreshAll(Object... entities)Refresh the state of the given objects.voidrefreshAll(Collection entities)Refresh the state of the given objects.voidrelease(Object entity)Release the given object from management.voidreleaseAll(Object... entities)Release the given object from management.voidreleaseAll(Collection entities)Release the given objects from management.voidreleaseSavepoint()Release the last set savepoint and any resources associated with it.voidreleaseSavepoint(String name)Release the savepoint and any resources associated with it.voidremove(Object entity)voidremoveAll(Object... entities)Delete the given persistent objects.voidremoveAll(Collection entities)Delete the given persistent objects.voidremoveLifecycleListener(Object listener)Remove a listener for lifecycle-related events.voidremoveTransactionListener(Object listener)Remove a listener for transaction-related events.voidretrieve(Object entity)Immediately load the given object's persistent fields.voidretrieveAll(Object... entities)Retrieve the persistent state of the given objects.voidretrieveAll(Collection entities)Retrieve the persistent state of the given objects.voidrollback()voidrollbackAndResume()Issue a rollback and then start a new transaction.voidrollbackToSavepoint()Rollback the current transaction to the last savepoint.voidrollbackToSavepoint(String name)Rollback the current transaction to the given savepoint name.voidsetAutoClear(int autoClear)voidsetAutoClear(AutoClearType val)Whether to clear state when entering a transaction.voidsetAutoDetach(int autoDetachFlags)voidsetAutoDetach(int flag, boolean on)voidsetAutoDetach(EnumSet<AutoDetachType> flags)AutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.voidsetAutoDetach(AutoDetachType flag)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)voidsetDetachState(DetachStateType type)Detach 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.voidsetFlushMode(jakarta.persistence.FlushModeType flushMode)voidsetIgnoreChanges(boolean val)Whether to take into account changes in the transaction when executing a query or iterating an extent.voidsetLargeTransaction(boolean value)voidsetLifecycleListenerCallbackMode(int callbackMode)voidsetLifecycleListenerCallbackMode(EnumSet<CallbackMode> modes)TheCallbackModeflags for handling lifecycle listener exceptions.voidsetLifecycleListenerCallbackMode(CallbackMode mode)TheCallbackModeflag for handling lifecycle listener exceptions.voidsetMultithreaded(boolean multithreaded)Whether the entity manager or its managed instances are used in a multithreaded environment.voidsetNontransactionalRead(boolean val)Whether to allow nontransactional access to persistent state.voidsetNontransactionalWrite(boolean val)Whether to allow nontransactional changes to persistent state.voidsetOptimistic(boolean val)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.voidsetProperties(Map<String,Object> emEmptyPropsProperties)voidsetProperty(String prop, Object value)Sets the given property to the given value, reflectively.voidsetQuerySQLCache(boolean flag)Sets whether this receiver will cache database queries during its lifetime.voidsetRestoreState(int restore)voidsetRestoreState(RestoreStateType val)Whether to restore an object's original state on rollback.voidsetRetainState(boolean val)Whether objects retain their persistent state on transaction commit.voidsetRollbackOnly()voidsetRollbackOnly(Throwable cause)Mark the current transaction for rollback with the specified cause of the rollback.voidsetSavepoint(String name)Set a transactional savepoint where operations after this savepoint will be rolled back.voidsetSyncWithManagedTransactions(boolean sync)Whether to check for a global transaction upon every managed, non-transactional operation.voidsetTrackChangesByType(boolean trackByType)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)voidsetTransactionListenerCallbackMode(EnumSet<CallbackMode> modes)TheCallbackModeflags for handling transaction listener exceptions.voidsetTransactionListenerCallbackMode(CallbackMode mode)TheCallbackModeflag for handling transaction listener exceptions.voidtransactional(Object entity, 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.<T> Tunwrap(Class<T> cls)Unwraps this receiver to an instance of the given class, if possible.voidvalidateChanges()Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc.protected voidvalidateSQL(String query)Validate that the user provided SQL.voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
_ret
protected RuntimeExceptionTranslator _ret
-
-
Constructor Detail
-
EntityManagerImpl
public EntityManagerImpl()
-
EntityManagerImpl
public EntityManagerImpl(EntityManagerFactoryImpl factory, Broker broker)
Constructor; supply factory and delegate.
-
-
Method Detail
-
getBroker
public Broker getBroker()
Broker delegate.
-
getEntityManagerFactory
public OpenJPAEntityManagerFactory getEntityManagerFactory()
Description copied from interface:OpenJPAEntityManagerReturn the factory that produced this entity manager.- Specified by:
getEntityManagerFactoryin interfacejakarta.persistence.EntityManager- Specified by:
getEntityManagerFactoryin interfaceOpenJPAEntityManager
-
getConfiguration
public OpenJPAConfiguration getConfiguration()
Description copied from interface:OpenJPAEntityManagerSPIReturn the configuration associated with this entity manager.- Specified by:
getConfigurationin interfaceOpenJPAEntityManager- Specified by:
getConfigurationin interfaceOpenJPAEntityManagerSPI
-
getFetchPlan
public FetchPlan getFetchPlan()
Description copied from interface:OpenJPAEntityManagerReturn the (mutable) fetch plan for loading objects from this entity manager.- Specified by:
getFetchPlanin interfaceOpenJPAEntityManager
-
pushFetchPlan
public FetchPlan pushFetchPlan()
Description copied from interface:OpenJPAEntityManagerPushes a new fetch plan that inherits from the current fetch plan onto a stack, and makes the new plan the active one.- Specified by:
pushFetchPlanin interfaceOpenJPAEntityManager- Returns:
- the new fetch plan
-
pushFetchPlan
public FetchPlan pushFetchPlan(FetchConfiguration fc)
-
popFetchPlan
public void popFetchPlan()
Description copied from interface:OpenJPAEntityManagerPops 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.- Specified by:
popFetchPlanin interfaceOpenJPAEntityManager
-
getConnectionRetainMode
public ConnectionRetainMode getConnectionRetainMode()
Description copied from interface:OpenJPAEntityManagerReturn the connection retain mode for this entity manager.- Specified by:
getConnectionRetainModein interfaceOpenJPAEntityManager
-
isTransactionManaged
public boolean isTransactionManaged()
Description copied from interface:OpenJPAEntityManagerWhether this entity manager is using managed transactions.- Specified by:
isTransactionManagedin interfaceOpenJPAEntityManager
-
isManaged
public boolean isManaged()
- Specified by:
isManagedin interfaceOpenJPAEntityManager
-
getManagedRuntime
public ManagedRuntime getManagedRuntime()
Description copied from interface:OpenJPAEntityManagerSPIReturn the managed runtime in use.- Specified by:
getManagedRuntimein interfaceOpenJPAEntityManagerSPI
-
getSyncWithManagedTransactions
public boolean getSyncWithManagedTransactions()
Description copied from interface:OpenJPAEntityManagerWhether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
getSyncWithManagedTransactionsin interfaceOpenJPAEntityManager
-
setSyncWithManagedTransactions
public void setSyncWithManagedTransactions(boolean sync)
Description copied from interface:OpenJPAEntityManagerWhether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
setSyncWithManagedTransactionsin interfaceOpenJPAEntityManager
-
getClassLoader
public ClassLoader getClassLoader()
Description copied from interface:OpenJPAEntityManagerReturn the current thread's class loader at the time this entity manager was obtained from the factory.- Specified by:
getClassLoaderin interfaceOpenJPAEntityManager
-
getConnectionUserName
public String getConnectionUserName()
Description copied from interface:OpenJPAEntityManagerReturn the connection user name.- Specified by:
getConnectionUserNamein interfaceOpenJPAEntityManager
-
getConnectionPassword
public String getConnectionPassword()
Description copied from interface:OpenJPAEntityManagerReturn the connection password.- Specified by:
getConnectionPasswordin interfaceOpenJPAEntityManager
-
getMultithreaded
public boolean getMultithreaded()
Description copied from interface:OpenJPAEntityManagerWhether the entity manager or its managed instances are used in a multithreaded environment.- Specified by:
getMultithreadedin interfaceOpenJPAEntityManager
-
setMultithreaded
public void setMultithreaded(boolean multithreaded)
Description copied from interface:OpenJPAEntityManagerWhether the entity manager or its managed instances are used in a multithreaded environment.- Specified by:
setMultithreadedin interfaceOpenJPAEntityManager
-
getIgnoreChanges
public boolean getIgnoreChanges()
Description copied from interface:OpenJPAEntityManagerWhether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
getIgnoreChangesin interfaceOpenJPAEntityManager
-
setIgnoreChanges
public void setIgnoreChanges(boolean val)
Description copied from interface:OpenJPAEntityManagerWhether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
setIgnoreChangesin interfaceOpenJPAEntityManager
-
getNontransactionalRead
public boolean getNontransactionalRead()
Description copied from interface:OpenJPAEntityManagerWhether to allow nontransactional access to persistent state.- Specified by:
getNontransactionalReadin interfaceOpenJPAEntityManager
-
setNontransactionalRead
public void setNontransactionalRead(boolean val)
Description copied from interface:OpenJPAEntityManagerWhether to allow nontransactional access to persistent state.- Specified by:
setNontransactionalReadin interfaceOpenJPAEntityManager
-
getNontransactionalWrite
public boolean getNontransactionalWrite()
Description copied from interface:OpenJPAEntityManagerWhether to allow nontransactional changes to persistent state.- Specified by:
getNontransactionalWritein interfaceOpenJPAEntityManager
-
setNontransactionalWrite
public void setNontransactionalWrite(boolean val)
Description copied from interface:OpenJPAEntityManagerWhether to allow nontransactional changes to persistent state.- Specified by:
setNontransactionalWritein interfaceOpenJPAEntityManager
-
getOptimistic
public boolean getOptimistic()
Description copied from interface:OpenJPAEntityManagerWhether to use optimistic transactional semantics.- Specified by:
getOptimisticin interfaceOpenJPAEntityManager
-
setOptimistic
public void setOptimistic(boolean val)
Description copied from interface:OpenJPAEntityManagerWhether to use optimistic transactional semantics.- Specified by:
setOptimisticin interfaceOpenJPAEntityManager
-
getRestoreState
public RestoreStateType getRestoreState()
Description copied from interface:OpenJPAEntityManagerWhether to restore an object's original state on rollback.- Specified by:
getRestoreStatein interfaceOpenJPAEntityManager
-
setRestoreState
public void setRestoreState(RestoreStateType val)
Description copied from interface:OpenJPAEntityManagerWhether to restore an object's original state on rollback.- Specified by:
setRestoreStatein interfaceOpenJPAEntityManager
-
setRestoreState
public void setRestoreState(int restore)
- Specified by:
setRestoreStatein interfaceOpenJPAEntityManager
-
getRetainState
public boolean getRetainState()
Description copied from interface:OpenJPAEntityManagerWhether objects retain their persistent state on transaction commit.- Specified by:
getRetainStatein interfaceOpenJPAEntityManager
-
setRetainState
public void setRetainState(boolean val)
Description copied from interface:OpenJPAEntityManagerWhether objects retain their persistent state on transaction commit.- Specified by:
setRetainStatein interfaceOpenJPAEntityManager
-
getAutoClear
public AutoClearType getAutoClear()
Description copied from interface:OpenJPAEntityManagerWhether to clear state when entering a transaction.- Specified by:
getAutoClearin interfaceOpenJPAEntityManager
-
setAutoClear
public void setAutoClear(AutoClearType val)
Description copied from interface:OpenJPAEntityManagerWhether to clear state when entering a transaction.- Specified by:
setAutoClearin interfaceOpenJPAEntityManager
-
setAutoClear
public void setAutoClear(int autoClear)
- Specified by:
setAutoClearin interfaceOpenJPAEntityManager
-
getDetachState
public DetachStateType getDetachState()
Description copied from interface:OpenJPAEntityManagerDetach mode constant to determine which fields are part of the detached graph.- Specified by:
getDetachStatein interfaceOpenJPAEntityManager
-
setDetachState
public void setDetachState(DetachStateType type)
Description copied from interface:OpenJPAEntityManagerDetach mode constant to determine which fields are part of the detached graph.- Specified by:
setDetachStatein interfaceOpenJPAEntityManager
-
setDetachState
public void setDetachState(int detach)
- Specified by:
setDetachStatein interfaceOpenJPAEntityManager
-
getAutoDetach
public EnumSet<AutoDetachType> getAutoDetach()
Description copied from interface:OpenJPAEntityManagerAutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place.- Specified by:
getAutoDetachin interfaceOpenJPAEntityManager
-
setAutoDetach
public void setAutoDetach(AutoDetachType flag)
Description copied from interface:OpenJPAEntityManagerAutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place. The current value is replaced in its entirety.- Specified by:
setAutoDetachin interfaceOpenJPAEntityManager
-
setAutoDetach
public void setAutoDetach(EnumSet<AutoDetachType> flags)
Description copied from interface:OpenJPAEntityManagerAutoDetachTypevalues which indicate when persistent managed objects should be automatically detached in-place. The current value is replaced in its entirety.- Specified by:
setAutoDetachin interfaceOpenJPAEntityManager
-
setAutoDetach
public void setAutoDetach(int autoDetachFlags)
- Specified by:
setAutoDetachin interfaceOpenJPAEntityManager
-
setAutoDetach
public void setAutoDetach(AutoDetachType value, boolean on)
Description copied from interface:OpenJPAEntityManagerBit flags marked inAutoDetachTypewhich indicate when persistent managed objects should be automatically detached in-place.- Specified by:
setAutoDetachin interfaceOpenJPAEntityManager
-
setAutoDetach
public void setAutoDetach(int flag, boolean on)- Specified by:
setAutoDetachin interfaceOpenJPAEntityManager
-
getEvictFromStoreCache
public boolean getEvictFromStoreCache()
Description copied from interface:OpenJPAEntityManagerWhether to also evict an object from the store cache when it is evicted through this entity manager.- Specified by:
getEvictFromStoreCachein interfaceOpenJPAEntityManager
-
setEvictFromStoreCache
public void setEvictFromStoreCache(boolean evict)
Description copied from interface:OpenJPAEntityManagerWhether to also evict an object from the store cache when it is evicted through this entity manager.- Specified by:
setEvictFromStoreCachein interfaceOpenJPAEntityManager
-
getPopulateStoreCache
public boolean getPopulateStoreCache()
Description copied from interface:OpenJPAEntityManagerWhether objects accessed during this transaction will be added to the store cache. Defaults to true.- Specified by:
getPopulateStoreCachein interfaceOpenJPAEntityManager
-
setPopulateStoreCache
public void setPopulateStoreCache(boolean cache)
Description copied from interface:OpenJPAEntityManagerWhether to populate the store cache with objects used by this transaction. Defaults to true.- Specified by:
setPopulateStoreCachein interfaceOpenJPAEntityManager
-
isTrackChangesByType
public boolean isTrackChangesByType()
Description copied from interface:OpenJPAEntityManagerWhether 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.- Specified by:
isTrackChangesByTypein interfaceOpenJPAEntityManager
-
setTrackChangesByType
public void setTrackChangesByType(boolean trackByType)
Description copied from interface:OpenJPAEntityManagerIf 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.- Specified by:
setTrackChangesByTypein interfaceOpenJPAEntityManager
-
isLargeTransaction
public boolean isLargeTransaction()
- Specified by:
isLargeTransactionin interfaceOpenJPAEntityManager
-
setLargeTransaction
public void setLargeTransaction(boolean value)
- Specified by:
setLargeTransactionin interfaceOpenJPAEntityManager
-
getUserObject
public Object getUserObject(Object key)
Description copied from interface:OpenJPAEntityManagerGet the value for the specified key from the map of user objects.- Specified by:
getUserObjectin interfaceOpenJPAEntityManager
-
putUserObject
public Object putUserObject(Object key, Object val)
Description copied from interface:OpenJPAEntityManagerPut the specified key-value pair into the map of user objects. Use a value of null to remove the key.- Specified by:
putUserObjectin interfaceOpenJPAEntityManager
-
addTransactionListener
public void addTransactionListener(Object listener)
Description copied from interface:OpenJPAEntityManagerSPIRegister a listener for transaction-related events.- Specified by:
addTransactionListenerin interfaceOpenJPAEntityManager- Specified by:
addTransactionListenerin interfaceOpenJPAEntityManagerSPI
-
removeTransactionListener
public void removeTransactionListener(Object listener)
Description copied from interface:OpenJPAEntityManagerSPIRemove a listener for transaction-related events.- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManager- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManagerSPI
-
getTransactionListenerCallbackModes
public EnumSet<CallbackMode> getTransactionListenerCallbackModes()
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflags for handling transaction listener exceptions.- Specified by:
getTransactionListenerCallbackModesin interfaceOpenJPAEntityManagerSPI
-
setTransactionListenerCallbackMode
public void setTransactionListenerCallbackMode(CallbackMode mode)
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflag for handling transaction listener exceptions. The flags provided here will entirely replace the previous settings.- Specified by:
setTransactionListenerCallbackModein interfaceOpenJPAEntityManagerSPI
-
setTransactionListenerCallbackMode
public void setTransactionListenerCallbackMode(EnumSet<CallbackMode> modes)
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflags for handling transaction listener exceptions. The flags provided here will entirely replace the previous settings.- Specified by:
setTransactionListenerCallbackModein interfaceOpenJPAEntityManagerSPI
-
getTransactionListenerCallbackMode
public int getTransactionListenerCallbackMode()
- Specified by:
getTransactionListenerCallbackModein interfaceOpenJPAEntityManager
-
setTransactionListenerCallbackMode
public void setTransactionListenerCallbackMode(int callbackMode)
- Specified by:
setTransactionListenerCallbackModein interfaceOpenJPAEntityManager
-
addLifecycleListener
public void addLifecycleListener(Object listener, Class... classes)
Description copied from interface:OpenJPAEntityManagerSPIRegister a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener.- Specified by:
addLifecycleListenerin interfaceOpenJPAEntityManager- Specified by:
addLifecycleListenerin interfaceOpenJPAEntityManagerSPI
-
removeLifecycleListener
public void removeLifecycleListener(Object listener)
Description copied from interface:OpenJPAEntityManagerSPIRemove a listener for lifecycle-related events.- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManager- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManagerSPI
-
getLifecycleListenerCallbackModes
public EnumSet<CallbackMode> getLifecycleListenerCallbackModes()
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflags for handling lifecycle listener exceptions.- Specified by:
getLifecycleListenerCallbackModesin interfaceOpenJPAEntityManagerSPI
-
setLifecycleListenerCallbackMode
public void setLifecycleListenerCallbackMode(CallbackMode mode)
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflag for handling lifecycle listener exceptions. The flags provided here will entirely replace the previous settings.- Specified by:
setLifecycleListenerCallbackModein interfaceOpenJPAEntityManagerSPI
-
setLifecycleListenerCallbackMode
public void setLifecycleListenerCallbackMode(EnumSet<CallbackMode> modes)
Description copied from interface:OpenJPAEntityManagerSPITheCallbackModeflags for handling lifecycle listener exceptions. The flags provided here will entirely replace the previous settings.- Specified by:
setLifecycleListenerCallbackModein interfaceOpenJPAEntityManagerSPI
-
getLifecycleListenerCallbackMode
public int getLifecycleListenerCallbackMode()
- Specified by:
getLifecycleListenerCallbackModein interfaceOpenJPAEntityManager
-
setLifecycleListenerCallbackMode
public void setLifecycleListenerCallbackMode(int callbackMode)
- Specified by:
setLifecycleListenerCallbackModein interfaceOpenJPAEntityManager
-
getReference
public <T> T getReference(Class<T> cls, Object oid)
- Specified by:
getReferencein interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> cls, Object oid)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> cls, Object oid, jakarta.persistence.LockModeType mode)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> cls, Object oid, Map<String,Object> properties)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> cls, Object oid, jakarta.persistence.LockModeType mode, Map<String,Object> properties)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
findAll
public <T> T[] findAll(Class<T> cls, Object... oids)
Description copied from interface:OpenJPAEntityManagerReturn the objects with the given oids.- Specified by:
findAllin interfaceOpenJPAEntityManageroids- 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
public <T> Collection<T> findAll(Class<T> cls, Collection oids)
Description copied from interface:OpenJPAEntityManagerReturn the objects with the given oids.- Specified by:
findAllin interfaceOpenJPAEntityManageroids- 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
public <T> T findCached(Class<T> cls, Object oid)
Description copied from interface:OpenJPAEntityManagerReturn the cached instance for the given oid/object, or null if not cached.- Specified by:
findCachedin interfaceOpenJPAEntityManageroid- the object's id- Returns:
- the cached object, or null if not cached
-
getObjectIdClass
public Class getObjectIdClass(Class cls)
Description copied from interface:OpenJPAEntityManagerReturn the application identity class the given persistent class uses for object ids, or null if not a type that uses application identity.- Specified by:
getObjectIdClassin interfaceOpenJPAEntityManager
-
getTransaction
public OpenJPAEntityTransaction getTransaction()
- Specified by:
getTransactionin interfacejakarta.persistence.EntityManager- Specified by:
getTransactionin interfaceOpenJPAEntityManager
-
joinTransaction
public void joinTransaction()
- Specified by:
joinTransactionin interfacejakarta.persistence.EntityManager
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
- Specified by:
isJoinedToTransactionin interfacejakarta.persistence.EntityManager
-
begin
public void begin()
- Specified by:
beginin interfacejakarta.persistence.EntityTransaction- Specified by:
beginin interfaceOpenJPAEntityManager
-
commit
public void commit()
- Specified by:
commitin interfacejakarta.persistence.EntityTransaction- Specified by:
commitin interfaceOpenJPAEntityManager
-
rollback
public void rollback()
- Specified by:
rollbackin interfacejakarta.persistence.EntityTransaction- Specified by:
rollbackin interfaceOpenJPAEntityManager
-
commitAndResume
public void commitAndResume()
Description copied from interface:OpenJPAEntityTransactionIssue a commit and then start a new transaction. This is identical to:manager.commit (); manager.begin ();
except that the entity manager's internal atomic lock is utilized, so this method can be safely executed from multiple threads.- Specified by:
commitAndResumein interfaceOpenJPAEntityManager- Specified by:
commitAndResumein interfaceOpenJPAEntityTransaction- See Also:
EntityTransaction.commit(),EntityTransaction.begin()
-
rollbackAndResume
public void rollbackAndResume()
Description copied from interface:OpenJPAEntityTransactionIssue a rollback and then start a new transaction. This is identical to:manager.rollback (); manager.begin ();
except that the entity manager's internal atomic lock is utilized, so this method can be safely executed from multiple threads.- Specified by:
rollbackAndResumein interfaceOpenJPAEntityManager- Specified by:
rollbackAndResumein interfaceOpenJPAEntityTransaction- See Also:
EntityTransaction.rollback(),EntityTransaction.begin()
-
getRollbackCause
public Throwable getRollbackCause()
Description copied from interface:OpenJPAEntityTransactionReturns the Throwable that caused the transaction to be marked for rollback.- Specified by:
getRollbackCausein interfaceOpenJPAEntityManager- Specified by:
getRollbackCausein interfaceOpenJPAEntityTransaction- Returns:
- the Throwable, or null if none was given
-
getRollbackOnly
public boolean getRollbackOnly()
- Specified by:
getRollbackOnlyin interfacejakarta.persistence.EntityTransaction- Specified by:
getRollbackOnlyin interfaceOpenJPAEntityManager
-
setRollbackOnly
public void setRollbackOnly()
- Specified by:
setRollbackOnlyin interfacejakarta.persistence.EntityTransaction- Specified by:
setRollbackOnlyin interfaceOpenJPAEntityManager
-
setRollbackOnly
public void setRollbackOnly(Throwable cause)
Description copied from interface:OpenJPAEntityTransactionMark the current transaction for rollback with the specified cause of the rollback.- Specified by:
setRollbackOnlyin interfaceOpenJPAEntityManager- Specified by:
setRollbackOnlyin interfaceOpenJPAEntityTransaction
-
setSavepoint
public void setSavepoint(String name)
Description copied from interface:OpenJPAEntityManagerSet a transactional savepoint where operations after this savepoint will be rolled back.- Specified by:
setSavepointin interfaceOpenJPAEntityManager
-
rollbackToSavepoint
public void rollbackToSavepoint()
Description copied from interface:OpenJPAEntityManagerRollback the current transaction to the last savepoint. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepointin interfaceOpenJPAEntityManager
-
rollbackToSavepoint
public void rollbackToSavepoint(String name)
Description copied from interface:OpenJPAEntityManagerRollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepointin interfaceOpenJPAEntityManager
-
releaseSavepoint
public void releaseSavepoint()
Description copied from interface:OpenJPAEntityManagerRelease the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepointin interfaceOpenJPAEntityManager
-
releaseSavepoint
public void releaseSavepoint(String name)
Description copied from interface:OpenJPAEntityManagerRelease the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepointin interfaceOpenJPAEntityManager
-
flush
public void flush()
- Specified by:
flushin interfacejakarta.persistence.EntityManager
-
preFlush
public void preFlush()
Description copied from interface:OpenJPAEntityManagerRun 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.- Specified by:
preFlushin interfaceOpenJPAEntityManager
-
validateChanges
public void validateChanges()
Description copied from interface:OpenJPAEntityManagerValidate 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.- Specified by:
validateChangesin interfaceOpenJPAEntityManager
-
isActive
public boolean isActive()
- Specified by:
isActivein interfacejakarta.persistence.EntityTransaction- Specified by:
isActivein interfaceOpenJPAEntityManager
-
isStoreActive
public boolean isStoreActive()
Description copied from interface:OpenJPAEntityManagerWhether a store transaction is active.- Specified by:
isStoreActivein interfaceOpenJPAEntityManager
-
beginStore
public void beginStore()
Description copied from interface:OpenJPAEntityManagerBegins a store transaction if one isn't already started. The entity manager must already be in a logical transaction.- Specified by:
beginStorein interfaceOpenJPAEntityManager
-
contains
public boolean contains(Object entity)
- Specified by:
containsin interfacejakarta.persistence.EntityManager
-
containsAll
public boolean containsAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerWhether the given objects are managed.- Specified by:
containsAllin interfaceOpenJPAEntityManager
-
containsAll
public boolean containsAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerWhether the given objects are managed.- Specified by:
containsAllin interfaceOpenJPAEntityManager
-
persist
public void persist(Object entity)
- Specified by:
persistin interfacejakarta.persistence.EntityManager
-
persistAll
public void persistAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerPersist the given objects.- Specified by:
persistAllin interfaceOpenJPAEntityManager
-
persistAll
public void persistAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerPersist the given objects.- Specified by:
persistAllin interfaceOpenJPAEntityManager
-
remove
public void remove(Object entity)
- Specified by:
removein interfacejakarta.persistence.EntityManager
-
removeAll
public void removeAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerDelete the given persistent objects.- Specified by:
removeAllin interfaceOpenJPAEntityManager
-
removeAll
public void removeAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerDelete the given persistent objects.- Specified by:
removeAllin interfaceOpenJPAEntityManager
-
release
public void release(Object entity)
Description copied from interface:OpenJPAEntityManagerRelease the given object from management. This operation is not recursive.- Specified by:
releasein interfaceOpenJPAEntityManager
-
releaseAll
public void releaseAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerRelease the given objects from management. This operation is not recursive.- Specified by:
releaseAllin interfaceOpenJPAEntityManager
-
releaseAll
public void releaseAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerRelease the given object from management. This operation is not recursive.- Specified by:
releaseAllin interfaceOpenJPAEntityManager
-
refresh
public void refresh(Object entity)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType mode)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, Map<String,Object> properties)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType mode, Map<String,Object> properties)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refreshAll
public void refreshAll()
Description copied from interface:OpenJPAEntityManagerRefresh all transactional objects.- Specified by:
refreshAllin interfaceOpenJPAEntityManager
-
refreshAll
public void refreshAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerRefresh the state of the given objects.- Specified by:
refreshAllin interfaceOpenJPAEntityManager
-
refreshAll
public void refreshAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerRefresh the state of the given objects.- Specified by:
refreshAllin interfaceOpenJPAEntityManager
-
retrieve
public void retrieve(Object entity)
Description copied from interface:OpenJPAEntityManagerImmediately 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.- Specified by:
retrievein interfaceOpenJPAEntityManager
-
retrieveAll
public void retrieveAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerRetrieve the persistent state of the given objects.- Specified by:
retrieveAllin interfaceOpenJPAEntityManager- See Also:
OpenJPAEntityManager.retrieve(java.lang.Object)
-
retrieveAll
public void retrieveAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerRetrieve the persistent state of the given objects.- Specified by:
retrieveAllin interfaceOpenJPAEntityManager- See Also:
OpenJPAEntityManager.retrieve(java.lang.Object)
-
evict
public void evict(Object entity)
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictin interfaceOpenJPAEntityManager- Parameters:
entity- A persistent class which will be evicted
-
evictAll
public void evictAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictAllin interfaceOpenJPAEntityManager- Parameters:
entities- A collection of persistent classes which will be evicted.
-
evictAll
public void evictAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictAllin interfaceOpenJPAEntityManager- Parameters:
entities- The persistent classes which will be evicted
-
evictAll
public void evictAll()
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictAllin interfaceOpenJPAEntityManager
-
evictAll
public void evictAll(Class cls)
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictAllin interfaceOpenJPAEntityManager- Parameters:
cls- All clean instances of this class will be evicted.
-
evictAll
public void evictAll(Extent extent)
Description copied from interface:OpenJPAEntityManagerEvict 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.
- Specified by:
evictAllin interfaceOpenJPAEntityManager- Parameters:
extent- Extend which contains the persistent classes to evict.
-
detachCopy
public <T> T detachCopy(T entity)
Description copied from interface:OpenJPAEntityManagerDetach the specified object from the entity manager, detaching based on the AutoDetach value specified and returning a copy of the detached entity.- Specified by:
detachCopyin interfaceOpenJPAEntityManager- Parameters:
entity- the instance to detach- Returns:
- the detached instance
-
detachAll
public Object[] detachAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerDetach the specified objects from the entity manager.- Specified by:
detachAllin interfaceOpenJPAEntityManager- Parameters:
entities- the instances to detach- Returns:
- the detached instances
-
detachAll
public Collection detachAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerDetach the specified objects from the entity manager.- Specified by:
detachAllin interfaceOpenJPAEntityManager- Parameters:
entities- the instances to detach- Returns:
- the detached instances
-
merge
public <T> T merge(T entity)
- Specified by:
mergein interfacejakarta.persistence.EntityManager
-
mergeAll
public Object[] mergeAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerMerge the specified objects into the entity manager.- Specified by:
mergeAllin interfaceOpenJPAEntityManager- Parameters:
entities- instances to import- Returns:
- the re-attached instances
-
mergeAll
public Collection mergeAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerMerge the specified detached objects into the entity manager.- Specified by:
mergeAllin interfaceOpenJPAEntityManager- Parameters:
entities- Collection of instances to import- Returns:
- the re-attached instances
-
transactional
public void transactional(Object entity, boolean updateVersion)
Description copied from interface:OpenJPAEntityManagerMake the given object transactional.- Specified by:
transactionalin interfaceOpenJPAEntityManager- Parameters:
entity- instance to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
transactionalAll
public void transactionalAll(Collection objs, boolean updateVersion)
Description copied from interface:OpenJPAEntityManagerMake the given objects transactional.- Specified by:
transactionalAllin interfaceOpenJPAEntityManager- Parameters:
objs- instances to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
transactionalAll
public void transactionalAll(Object[] objs, boolean updateVersion)
Description copied from interface:OpenJPAEntityManagerMake the given objects transactional.- Specified by:
transactionalAllin interfaceOpenJPAEntityManager- Parameters:
objs- instances to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
nontransactional
public void nontransactional(Object entity)
Description copied from interface:OpenJPAEntityManagerMake the given object nontransactional.- Specified by:
nontransactionalin interfaceOpenJPAEntityManager
-
nontransactionalAll
public void nontransactionalAll(Collection objs)
Description copied from interface:OpenJPAEntityManagerMake the given objects nontransactional.- Specified by:
nontransactionalAllin interfaceOpenJPAEntityManager
-
nontransactionalAll
public void nontransactionalAll(Object[] objs)
Description copied from interface:OpenJPAEntityManagerMake the given objects nontransactional.- Specified by:
nontransactionalAllin interfaceOpenJPAEntityManager
-
getNamedGenerator
public Generator getNamedGenerator(String name)
Description copied from interface:OpenJPAEntityManagerReturn the named generator defined in the metadata.- Specified by:
getNamedGeneratorin interfaceOpenJPAEntityManager
-
getIdGenerator
public Generator getIdGenerator(Class forClass)
Description copied from interface:OpenJPAEntityManagerReturns 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.- Specified by:
getIdGeneratorin interfaceOpenJPAEntityManager
-
getFieldGenerator
public Generator getFieldGenerator(Class forClass, String fieldName)
Description copied from interface:OpenJPAEntityManagerReturns aGeneratorfor the generated values of the specified type, or null if the field is not generated.- Specified by:
getFieldGeneratorin interfaceOpenJPAEntityManager
-
createExtent
public <T> Extent<T> createExtent(Class<T> cls, boolean subclasses)
Description copied from interface:OpenJPAEntityManagerReturn an extent of the given class, optionally including subclasses.- Specified by:
createExtentin interfaceOpenJPAEntityManager
-
createQuery
public <T> jakarta.persistence.TypedQuery<T> createQuery(String query, Class<T> resultClass)
- Specified by:
createQueryin interfacejakarta.persistence.EntityManager
-
createQuery
public OpenJPAQuery createQuery(String query)
- Specified by:
createQueryin interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceOpenJPAEntityManager
-
createQuery
public OpenJPAQuery createQuery(String language, String query)
Description copied from interface:OpenJPAEntityManagerCreate a new query in the given language.- Specified by:
createQueryin interfaceOpenJPAEntityManager
-
createQuery
public OpenJPAQuery createQuery(jakarta.persistence.Query query)
Description copied from interface:OpenJPAEntityManagerCreate a new query from the given one.- Specified by:
createQueryin interfaceOpenJPAEntityManager
-
createNamedQuery
public <T> jakarta.persistence.TypedQuery<T> createNamedQuery(String name, Class<T> resultClass)
- Specified by:
createNamedQueryin interfacejakarta.persistence.EntityManager
-
createNamedQuery
public OpenJPAQuery createNamedQuery(String name)
- Specified by:
createNamedQueryin interfacejakarta.persistence.EntityManager- Specified by:
createNamedQueryin interfaceOpenJPAEntityManager
-
createNativeQuery
public OpenJPAQuery createNativeQuery(String query)
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager- Specified by:
createNativeQueryin interfaceOpenJPAEntityManager
-
createNativeQuery
public OpenJPAQuery createNativeQuery(String query, Class cls)
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager- Specified by:
createNativeQueryin interfaceOpenJPAEntityManager
-
createNativeQuery
public OpenJPAQuery createNativeQuery(String query, String mappingName)
- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager- Specified by:
createNativeQueryin interfaceOpenJPAEntityManager
-
createNamedStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createNamedStoredProcedureQuery(String name)
- Specified by:
createNamedStoredProcedureQueryin interfacejakarta.persistence.EntityManager
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName)
- Specified by:
createStoredProcedureQueryin interfacejakarta.persistence.EntityManager
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses)
- Specified by:
createStoredProcedureQueryin interfacejakarta.persistence.EntityManager
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings)
- Specified by:
createStoredProcedureQueryin interfacejakarta.persistence.EntityManager
-
newQueryImpl
protected <T> QueryImpl<T> newQueryImpl(Query kernelQuery, QueryMetaData qmd)
-
validateSQL
protected void validateSQL(String query)
Validate that the user provided SQL.
-
setFlushMode
public void setFlushMode(jakarta.persistence.FlushModeType flushMode)
- Specified by:
setFlushModein interfacejakarta.persistence.EntityManager
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
- Specified by:
getFlushModein interfacejakarta.persistence.EntityManager
-
prepareForPooling
@Deprecated public void prepareForPooling()
Deprecated.- useclear()instead.Used by Java EE Containers that wish to pool OpenJPA EntityManagers. The specification doesn't allow the closing of connections with the clear() method. By introducing this new method, we can do additional processing (and maybe more efficient processing) to properly prepare an EM for pooling.
-
clear
public void clear()
- Specified by:
clearin interfacejakarta.persistence.EntityManager
-
getDelegate
public Object getDelegate()
- Specified by:
getDelegatein interfacejakarta.persistence.EntityManager
-
getLockMode
public jakarta.persistence.LockModeType getLockMode(Object entity)
Description copied from interface:OpenJPAEntityManagerReturn the lock mode of the given instance, or null if not locked.- Specified by:
getLockModein interfacejakarta.persistence.EntityManager- Specified by:
getLockModein interfaceOpenJPAEntityManager
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType mode)
- Specified by:
lockin interfacejakarta.persistence.EntityManager
-
lock
public void lock(Object entity)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instance is locked at the current lock level, as set in theFetchPlanfor the entity manager.- Specified by:
lockin interfaceOpenJPAEntityManager
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType mode, int timeout)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instance is locked at the given lock level.- Specified by:
lockin interfaceOpenJPAEntityManager- Parameters:
entity- 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
public void lock(Object entity, jakarta.persistence.LockModeType mode, Map<String,Object> properties)
- Specified by:
lockin interfacejakarta.persistence.EntityManager
-
lockAll
public void lockAll(Collection entities)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.- Specified by:
lockAllin interfaceOpenJPAEntityManager
-
lockAll
public void lockAll(Collection entities, jakarta.persistence.LockModeType mode, int timeout)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instances are locked at the given lock level.- Specified by:
lockAllin interfaceOpenJPAEntityManager- Parameters:
entities- 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
public void lockAll(Object... entities)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instances are locked at the current lock level, as set in theFetchPlanfor the entity manager.- Specified by:
lockAllin interfaceOpenJPAEntityManager
-
lockAll
public void lockAll(Object[] entities, jakarta.persistence.LockModeType mode, int timeout)
Description copied from interface:OpenJPAEntityManagerEnsure that the given instances are locked at the given lock level.- Specified by:
lockAllin interfaceOpenJPAEntityManager- Parameters:
entities- 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
-
cancelAll
public boolean cancelAll()
Description copied from interface:OpenJPAEntityManagerCancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set.- Specified by:
cancelAllin interfaceOpenJPAEntityManager- Returns:
- true if any statements were cancelled, false otherwise
-
getConnection
public Object getConnection()
Description copied from interface:OpenJPAEntityManagerReturn the connection in use by the entity manager, or a new connection if none.- Specified by:
getConnectionin interfaceOpenJPAEntityManager
-
getManagedObjects
public Collection getManagedObjects()
Description copied from interface:OpenJPAEntityManagerReturn a set of all managed instances.- Specified by:
getManagedObjectsin interfaceOpenJPAEntityManager
-
getTransactionalObjects
public Collection getTransactionalObjects()
Description copied from interface:OpenJPAEntityManagerReturn a set of current transaction instances.- Specified by:
getTransactionalObjectsin interfaceOpenJPAEntityManager
-
getPendingTransactionalObjects
public Collection getPendingTransactionalObjects()
Description copied from interface:OpenJPAEntityManagerReturn a set of instances which will become transactional upon the next transaction.- Specified by:
getPendingTransactionalObjectsin interfaceOpenJPAEntityManager
-
getDirtyObjects
public Collection getDirtyObjects()
Description copied from interface:OpenJPAEntityManagerReturn a set of current dirty instances.- Specified by:
getDirtyObjectsin interfaceOpenJPAEntityManager
-
getOrderDirtyObjects
public boolean getOrderDirtyObjects()
Description copied from interface:OpenJPAEntityManagerWhether dirty objects will be returned in the order they were dirtied. Default is determined by the store manager.- Specified by:
getOrderDirtyObjectsin interfaceOpenJPAEntityManager
-
setOrderDirtyObjects
public void setOrderDirtyObjects(boolean order)
Description copied from interface:OpenJPAEntityManagerWhether dirty objects will be returned in the order they were dirtied. Default is determined by the store manager.- Specified by:
setOrderDirtyObjectsin interfaceOpenJPAEntityManager
-
dirtyClass
public void dirtyClass(Class cls)
Description copied from interface:OpenJPAEntityManagerMark the given class as dirty within the current transaction.- Specified by:
dirtyClassin interfaceOpenJPAEntityManager
-
getPersistedClasses
public Collection<Class> getPersistedClasses()
Description copied from interface:OpenJPAEntityManagerReturn the set of classes that have been made persistent in the current transaction.- Specified by:
getPersistedClassesin interfaceOpenJPAEntityManager
-
getUpdatedClasses
public Collection<Class> getUpdatedClasses()
Description copied from interface:OpenJPAEntityManagerReturn the set of classes for objects that have been modified in the current transaction.- Specified by:
getUpdatedClassesin interfaceOpenJPAEntityManager
-
getRemovedClasses
public Collection<Class> getRemovedClasses()
Description copied from interface:OpenJPAEntityManagerReturn the set of classes that have been deleted in the current transaction.- Specified by:
getRemovedClassesin interfaceOpenJPAEntityManager
-
createInstance
public <T> T createInstance(Class<T> cls)
Description copied from interface:OpenJPAEntityManagerCreate 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.- Specified by:
createInstancein interfaceOpenJPAEntityManager
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacejakarta.persistence.EntityManager
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejakarta.persistence.EntityManager
-
dirty
public void dirty(Object o, String field)
Description copied from interface:OpenJPAEntityManagerMake the named field of the given object dirty.- Specified by:
dirtyin interfaceOpenJPAEntityManager
-
getObjectId
public Object getObjectId(Object o)
Description copied from interface:OpenJPAEntityManagerReturn the oid of the given instance.- Specified by:
getObjectIdin interfaceOpenJPAEntityManager
-
isDirty
public boolean isDirty(Object o)
Description copied from interface:OpenJPAEntityManagerReturn whether the given object is dirty.- Specified by:
isDirtyin interfaceOpenJPAEntityManager
-
isTransactional
public boolean isTransactional(Object o)
Description copied from interface:OpenJPAEntityManagerReturn whether the given object is transactional.- Specified by:
isTransactionalin interfaceOpenJPAEntityManager
-
isPersistent
public boolean isPersistent(Object o)
Description copied from interface:OpenJPAEntityManagerReturn whether the given object is persistent.- Specified by:
isPersistentin interfaceOpenJPAEntityManager
-
isNewlyPersistent
public boolean isNewlyPersistent(Object o)
Description copied from interface:OpenJPAEntityManagerReturn whether the given object was made persistent in the current transaction.- Specified by:
isNewlyPersistentin interfaceOpenJPAEntityManager
-
isRemoved
public boolean isRemoved(Object o)
Description copied from interface:OpenJPAEntityManagerReturn whether the given object is deleted.- Specified by:
isRemovedin interfaceOpenJPAEntityManager
-
isDetached
public boolean isDetached(Object entity)
Description copied from interface:OpenJPAEntityManagerReturnstrueifpcis a detached object (one that can be reattached to aEntityManagervia a call toEntityManager.merge(T)); otherwise returnsfalse.- Specified by:
isDetachedin interfaceOpenJPAEntityManager
-
getVersion
public Object getVersion(Object o)
Description copied from interface:OpenJPAEntityManagerReturns the current version indicator foro.- Specified by:
getVersionin interfaceOpenJPAEntityManager
-
assertNotCloseInvoked
protected void assertNotCloseInvoked()
Throw appropriate exception if close has been invoked but the broker is still open. We test only for this because if the broker is already closed, it will throw its own more informative exception when we delegate the pending operation to it.
-
processArgument
public Object processArgument(Object arg)
Description copied from interface:FindCallbacksProcess find argument. Throw properOpenJPAExceptionfor illegal value.- Specified by:
processArgumentin interfaceFindCallbacks- Returns:
- the id to look up, or null to ignore this argument
-
processReturn
public Object processReturn(Object oid, OpenJPAStateManager sm)
Description copied from interface:FindCallbacksProcess operation return value.- Specified by:
processReturnin interfaceFindCallbacks- Returns:
- the object to return
-
processArgument
public int processArgument(int op, Object obj, OpenJPAStateManager sm)Description copied from interface:OpCallbacksProcess operation argument. Throw properOpenJPAExceptionfor illegal value.- Specified by:
processArgumentin interfaceOpCallbacks- Parameters:
op- the operation constantobj- the object passed to the operationsm- the argument's state manager, or null if none- Returns:
- the action to take on the argument
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
detach
public void detach(Object entity)
- Specified by:
detachin interfacejakarta.persistence.EntityManager
-
createQuery
public <T> jakarta.persistence.TypedQuery<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Create a query from the given CritriaQuery. Compile to register the parameters in this query.- Specified by:
createQueryin interfacejakarta.persistence.EntityManager
-
createQuery
public jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
- Specified by:
createQueryin interfacejakarta.persistence.EntityManager
-
createQuery
public jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
- Specified by:
createQueryin interfacejakarta.persistence.EntityManager
-
createDynamicQuery
public OpenJPAQuery createDynamicQuery(QueryDefinition qdef)
Description copied from interface:OpenJPAEntityManagerCreate an executable query from a dynamically defined query.- Specified by:
createDynamicQueryin interfaceOpenJPAEntityManager
-
getProperties
public Map<String,Object> getProperties()
Get the properties used currently by this entity manager. The property keys and their values are harvested from kernel artifacts namely the Broker and FetchPlan by reflection. These property keys and values that denote the bean properties/values of the kernel artifacts are converted to the original keys/values that user used to set the properties.- Specified by:
getPropertiesin interfacejakarta.persistence.EntityManager
-
getCriteriaBuilder
public OpenJPACriteriaBuilder getCriteriaBuilder()
Description copied from interface:OpenJPAEntityManagerGets the QueryBuilder with OpenJPA-extended capabilities.- Specified by:
getCriteriaBuilderin interfacejakarta.persistence.EntityManager- Specified by:
getCriteriaBuilderin interfaceOpenJPAEntityManager
-
getSupportedProperties
public Set<String> getSupportedProperties()
Description copied from interface:OpenJPAEntityManagerGet the properties supported by this runtime.- Specified by:
getSupportedPropertiesin interfaceOpenJPAEntityManager
-
unwrap
public <T> T unwrap(Class<T> cls)
Unwraps this receiver to an instance of the given class, if possible.- Specified by:
unwrapin interfacejakarta.persistence.EntityManager
-
setQuerySQLCache
public void setQuerySQLCache(boolean flag)
Description copied from interface:OpenJPAEntityManagerSPISets whether this receiver will cache database queries during its lifetime. The cache configured at BrokerFactory level is not affected by setting it inactive for this receiver.- Specified by:
setQuerySQLCachein interfaceOpenJPAEntityManagerSPI
-
getQuerySQLCache
public boolean getQuerySQLCache()
Description copied from interface:OpenJPAEntityManagerSPIAffirms if this receiver is caching database queries.- Specified by:
getQuerySQLCachein interfaceOpenJPAEntityManagerSPI
-
getMetamodel
public jakarta.persistence.metamodel.Metamodel getMetamodel()
- Specified by:
getMetamodelin interfacejakarta.persistence.EntityManager
-
createEntityGraph
public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType)
- Specified by:
createEntityGraphin interfacejakarta.persistence.EntityManager
-
createEntityGraph
public jakarta.persistence.EntityGraph<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraphin interfacejakarta.persistence.EntityManager
-
getEntityGraph
public jakarta.persistence.EntityGraph<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraphin interfacejakarta.persistence.EntityManager
-
getEntityGraphs
public <T> List<jakarta.persistence.EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
- Specified by:
getEntityGraphsin interfacejakarta.persistence.EntityManager
-
setProperty
public void setProperty(String prop, Object value)
Sets the given property to the given value, reflectively. The property key is transposed to a bean-style property. The value is converted to a type consumable by the kernel. After requisite transformation, if the value can not be set on either this instance or its fetch plan by reflection, then an warning message (not an exception as per JPA specification) is issued.- Specified by:
setPropertyin interfacejakarta.persistence.EntityManager
-
-