类 PersistenceManagerFactoryUtils
- java.lang.Object
- org.springframework.orm.jdo.PersistenceManagerFactoryUtils
public abstract class PersistenceManagerFactoryUtils extends Object
Helper class featuring methods for JDOPersistenceManager
handling, allowing for reuse of PersistenceManager instances within transactions. Also provides support for exception translation.Used internally by
JdoTransactionManager
. Can also be used directly in application code.- 从以下版本开始:
- 03.06.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
JdoTransactionManager
,JtaTransactionManager
,TransactionSynchronizationManager
字段概要
字段 修饰符和类型 字段 说明 static int
PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up JDO PersistenceManagers.
构造器概要
构造器 构造器 说明 PersistenceManagerFactoryUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
applyTransactionTimeout(javax.jdo.Query query, javax.jdo.PersistenceManagerFactory pmf)
Apply the current transaction timeout, if any, to the given JDO Query object.static DataAccessException
convertJdoAccessException(javax.jdo.JDOException ex)
Convert the given JDOException to an appropriate exception from theorg.springframework.dao
hierarchy.static javax.jdo.PersistenceManager
doGetPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate)
Obtain a JDO PersistenceManager via the given factory.static void
doReleasePersistenceManager(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
Actually release a PersistenceManager for the given factory.static javax.jdo.PersistenceManager
getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate)
Obtain a JDO PersistenceManager via the given factory.static boolean
isPersistenceManagerTransactional(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
Return whether the given JDO PersistenceManager is transactional, that is, bound to the current thread by Spring's transaction facilities.static void
releasePersistenceManager(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
Close the given PersistenceManager, created via the given factory, if it is not managed externally (i.e. not bound to the thread).
字段详细资料
PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
public static final int PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up JDO PersistenceManagers. Return DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100 to execute PersistenceManager cleanup before JDBC Connection cleanup, if any.
构造器详细资料
PersistenceManagerFactoryUtils
public PersistenceManagerFactoryUtils()
方法详细资料
getPersistenceManager
public static javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException
Obtain a JDO PersistenceManager via the given factory. Is aware of a corresponding PersistenceManager bound to the current thread, for example when using JdoTransactionManager. Will create a new PersistenceManager else, if "allowCreate" istrue
.- 参数:
pmf
- PersistenceManagerFactory to create the PersistenceManager withallowCreate
- if a non-transactional PersistenceManager should be created when no transactional PersistenceManager can be found for the current thread- 返回:
- the PersistenceManager
- 抛出:
DataAccessResourceFailureException
- if the PersistenceManager couldn't be obtainedIllegalStateException
- if no thread-bound PersistenceManager found and "allowCreate" isfalse
- 另请参阅:
JdoTransactionManager
doGetPersistenceManager
public static javax.jdo.PersistenceManager doGetPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate) throws javax.jdo.JDOException, IllegalStateException
Obtain a JDO PersistenceManager via the given factory. Is aware of a corresponding PersistenceManager bound to the current thread, for example when using JdoTransactionManager. Will create a new PersistenceManager else, if "allowCreate" istrue
.Same as
getPersistenceManager
, but throwing the original JDOException.- 参数:
pmf
- PersistenceManagerFactory to create the PersistenceManager withallowCreate
- if a non-transactional PersistenceManager should be created when no transactional PersistenceManager can be found for the current thread- 返回:
- the PersistenceManager
- 抛出:
javax.jdo.JDOException
- if the PersistenceManager couldn't be createdIllegalStateException
- if no thread-bound PersistenceManager found and "allowCreate" isfalse
- 另请参阅:
getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean)
,JdoTransactionManager
isPersistenceManagerTransactional
public static boolean isPersistenceManagerTransactional(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
Return whether the given JDO PersistenceManager is transactional, that is, bound to the current thread by Spring's transaction facilities.- 参数:
pm
- the JDO PersistenceManager to checkpmf
- JDO PersistenceManagerFactory that the PersistenceManager was created with (can benull
)- 返回:
- whether the PersistenceManager is transactional
applyTransactionTimeout
public static void applyTransactionTimeout(javax.jdo.Query query, javax.jdo.PersistenceManagerFactory pmf) throws javax.jdo.JDOException
Apply the current transaction timeout, if any, to the given JDO Query object.- 参数:
query
- the JDO Query objectpmf
- JDO PersistenceManagerFactory that the Query was created for- 抛出:
javax.jdo.JDOException
- if thrown by JDO methods
convertJdoAccessException
public static DataAccessException convertJdoAccessException(javax.jdo.JDOException ex)
Convert the given JDOException to an appropriate exception from theorg.springframework.dao
hierarchy.The most important cases like object not found or optimistic locking failure are covered here. For more fine-granular conversion, JdoTransactionManager supports sophisticated translation of exceptions via a JdoDialect.
- 参数:
ex
- JDOException that occured- 返回:
- the corresponding DataAccessException instance
- 另请参阅:
JdoTransactionManager.convertJdoAccessException(javax.jdo.JDOException)
,JdoDialect.translateException(javax.jdo.JDOException)
releasePersistenceManager
public static void releasePersistenceManager(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
Close the given PersistenceManager, created via the given factory, if it is not managed externally (i.e. not bound to the thread).- 参数:
pm
- PersistenceManager to closepmf
- PersistenceManagerFactory that the PersistenceManager was created with (can benull
)
doReleasePersistenceManager
public static void doReleasePersistenceManager(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf) throws javax.jdo.JDOException
Actually release a PersistenceManager for the given factory. Same asreleasePersistenceManager
, but throwing the original JDOException.- 参数:
pm
- PersistenceManager to closepmf
- PersistenceManagerFactory that the PersistenceManager was created with (can benull
)- 抛出:
javax.jdo.JDOException
- if thrown by JDO methods