public abstract class PersistenceManagerFactoryUtils extends Object
PersistenceManager 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.
JdoTransactionManager,
JtaTransactionManager,
TransactionSynchronizationManager| Modifier and Type | Field and Description |
|---|---|
static int |
PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up JDO
PersistenceManagers.
|
| Constructor and Description |
|---|
PersistenceManagerFactoryUtils() |
| Modifier and Type | Method and Description |
|---|---|
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 the
org.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.
|
public static final int PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
public static javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate)
throws DataAccessResourceFailureException,
IllegalStateException
true.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 threadDataAccessResourceFailureException - if the PersistenceManager couldn't be obtainedIllegalStateException - if no thread-bound PersistenceManager found and
"allowCreate" is falseJdoTransactionManagerpublic static javax.jdo.PersistenceManager doGetPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate)
throws javax.jdo.JDOException,
IllegalStateException
true.
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 threadjavax.jdo.JDOException - if the PersistenceManager couldn't be createdIllegalStateException - if no thread-bound PersistenceManager found and
"allowCreate" is falsegetPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean),
JdoTransactionManagerpublic static boolean isPersistenceManagerTransactional(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
pm - the JDO PersistenceManager to checkpmf - JDO PersistenceManagerFactory that the PersistenceManager
was created with (can be null)public static void applyTransactionTimeout(javax.jdo.Query query,
javax.jdo.PersistenceManagerFactory pmf)
throws javax.jdo.JDOException
query - the JDO Query objectpmf - JDO PersistenceManagerFactory that the Query was created forjavax.jdo.JDOException - if thrown by JDO methodspublic static DataAccessException convertJdoAccessException(javax.jdo.JDOException ex)
org.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 occuredJdoTransactionManager.convertJdoAccessException(javax.jdo.JDOException),
JdoDialect.translateException(javax.jdo.JDOException)public static void releasePersistenceManager(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
pm - PersistenceManager to closepmf - PersistenceManagerFactory that the PersistenceManager was created with
(can be null)public static void doReleasePersistenceManager(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
throws javax.jdo.JDOException
releasePersistenceManager, but throwing the original JDOException.pm - PersistenceManager to closepmf - PersistenceManagerFactory that the PersistenceManager was created with
(can be null)javax.jdo.JDOException - if thrown by JDO methods