|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.orm.jdo.PersistenceManagerFactoryUtils
public abstract class PersistenceManagerFactoryUtils
Helper class featuring methods for JDO PersistenceManager handling, allowing for reuse of PersistenceManager instances within transactions. Also provides support for exception translation.
Used internally by JdoTemplate
, JdoInterceptor
and
JdoTransactionManager
. Can also be used directly in application code.
JdoTransactionManager
,
JtaTransactionManager
,
TransactionSynchronizationManager
Nested Class Summary | |
---|---|
private static class |
PersistenceManagerFactoryUtils.PersistenceManagerSynchronization
Callback for resource cleanup at the end of a non-JDO transaction (e.g. |
Field Summary | |
---|---|
private static Log |
logger
|
static int |
PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up JDO PersistenceManagers. |
Constructor Summary | |
---|---|
PersistenceManagerFactoryUtils()
|
Method Summary | |
---|---|
static void |
applyTransactionTimeout(Query query,
PersistenceManagerFactory pmf,
JdoDialect jdoDialect)
Apply the current transaction timeout, if any, to the given JDO Query object. |
static DataAccessException |
convertJdoAccessException(JDOException ex)
Convert the given JDOException to an appropriate exception from the org.springframework.dao hierarchy. |
static PersistenceManager |
doGetPersistenceManager(PersistenceManagerFactory pmf,
boolean allowCreate)
Obtain a JDO PersistenceManager via the given factory. |
static void |
doReleasePersistenceManager(PersistenceManager pm,
PersistenceManagerFactory pmf)
Actually release a PersistenceManager for the given factory. |
static PersistenceManager |
getPersistenceManager(PersistenceManagerFactory pmf,
boolean allowCreate)
Obtain a JDO PersistenceManager via the given factory. |
static boolean |
isPersistenceManagerTransactional(PersistenceManager pm,
PersistenceManagerFactory pmf)
Return whether the given JDO PersistenceManager is transactional, that is, bound to the current thread by Spring's transaction facilities. |
(package private) static SQLExceptionTranslator |
newJdbcExceptionTranslator(java.lang.Object connectionFactory)
Create an appropriate SQLExceptionTranslator for the given PersistenceManagerFactory. |
static void |
releasePersistenceManager(PersistenceManager pm,
PersistenceManagerFactory pmf)
Close the given PersistenceManager, created via the given factory, if it is not managed externally (i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PERSISTENCE_MANAGER_SYNCHRONIZATION_ORDER
DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER
,
Constant Field Valuesprivate static final Log logger
Constructor Detail |
---|
public PersistenceManagerFactoryUtils()
Method Detail |
---|
static SQLExceptionTranslator newJdbcExceptionTranslator(java.lang.Object connectionFactory)
If a DataSource is found, creates a SQLErrorCodeSQLExceptionTranslator for the DataSource; else, falls back to a SQLStateSQLExceptionTranslator.
connectionFactory
- the connection factory of the PersistenceManagerFactory
(may be null
)
null
)javax.jdo.PersistenceManagerFactory#getConnectionFactory()
,
SQLErrorCodeSQLExceptionTranslator
,
SQLStateSQLExceptionTranslator
public static PersistenceManager getPersistenceManager(PersistenceManagerFactory pmf, boolean allowCreate) throws DataAccessResourceFailureException, java.lang.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 thread
DataAccessResourceFailureException
- if the PersistenceManager couldn't be obtained
java.lang.IllegalStateException
- if no thread-bound PersistenceManager found and
"allowCreate" is false
JdoTransactionManager
public static PersistenceManager doGetPersistenceManager(PersistenceManagerFactory pmf, boolean allowCreate) throws JDOException, java.lang.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 thread
JDOException
- if the PersistenceManager couldn't be created
java.lang.IllegalStateException
- if no thread-bound PersistenceManager found and
"allowCreate" is false
#getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean)
,
JdoTransactionManager
public static boolean isPersistenceManagerTransactional(PersistenceManager pm, PersistenceManagerFactory pmf)
pm
- the JDO PersistenceManager to checkpmf
- JDO PersistenceManagerFactory that the PersistenceManager
was created with (can be null
)
public static void applyTransactionTimeout(Query query, PersistenceManagerFactory pmf, JdoDialect jdoDialect) throws JDOException
query
- the JDO Query objectpmf
- JDO PersistenceManagerFactory that the Query was created forjdoDialect
- the JdoDialect to use for applying a query timeout
(must not be null
)
JDOException
- if thrown by JDO methodsJdoDialect.applyQueryTimeout(Query, int)
public static DataAccessException convertJdoAccessException(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, JdoAccessor and JdoTransactionManager support sophisticated translation of exceptions via a JdoDialect.
ex
- JDOException that occured
JdoAccessor.convertJdoAccessException(JDOException)
,
JdoTransactionManager.convertJdoAccessException(JDOException)
,
JdoDialect.translateException(JDOException)
public static void releasePersistenceManager(PersistenceManager pm, PersistenceManagerFactory pmf)
pm
- PersistenceManager to closepmf
- PersistenceManagerFactory that the PersistenceManager was created with
(can be null
)public static void doReleasePersistenceManager(PersistenceManager pm, PersistenceManagerFactory pmf) throws JDOException
releasePersistenceManager
, but throwing the original JDOException.
pm
- PersistenceManager to closepmf
- PersistenceManagerFactory that the PersistenceManager was created with
(can be null
)
JDOException
- if thrown by JDO methods
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |