|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.jdo.PersistenceManagerFactoryUtils
Helper class featuring methods for JDO PersistenceManager handling, allowing for reuse of PersistenceManager instances within transactions.
Used by JdoTemplate, JdoInterceptor, and JdoTransactionManager. Can also be used directly in application code, e.g. in combination with JdoInterceptor.
JdoTemplate
,
JdoInterceptor
,
JdoTransactionManager
Constructor Summary | |
PersistenceManagerFactoryUtils()
|
Method Summary | |
static void |
applyTransactionTimeout(javax.jdo.Query query,
javax.jdo.PersistenceManagerFactory pmf,
JdoDialect jdoDialect)
Apply the current transaction timeout, if any, to the given JDO Query object. |
static void |
closePersistenceManagerIfNecessary(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
Close the given PersistenceManager, created via the given factory, if it isn't bound to the thread. |
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 |
getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate)
Get a JDO PersistenceManager via the given factory. |
static javax.jdo.PersistenceManager |
getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate,
boolean allowSynchronization)
Get a JDO PersistenceManager via the given factory. |
static SQLExceptionTranslator |
newJdbcExceptionTranslator(javax.jdo.PersistenceManagerFactory pmf)
Create an appropriate SQLExceptionTranslator for the given PersistenceManagerFactory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PersistenceManagerFactoryUtils()
Method Detail |
public static SQLExceptionTranslator newJdbcExceptionTranslator(javax.jdo.PersistenceManagerFactory pmf)
pmf
- the PersistenceManagerFactory to create the translator for
PersistenceManagerFactory.getConnectionFactory()
,
SQLErrorCodeSQLExceptionTranslator
,
SQLStateSQLExceptionTranslator
public static javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate) throws DataAccessResourceFailureException, java.lang.IllegalStateException
pmf
- PersistenceManagerFactory to create the session withallowCreate
- if a new PersistenceManager should be created if no thread-bound found
DataAccessResourceFailureException
- if the PersistenceManager couldn't be created
java.lang.IllegalStateException
- if no thread-bound PersistenceManager found and allowCreate falsepublic static javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf, boolean allowCreate, boolean allowSynchronization) throws DataAccessResourceFailureException, java.lang.IllegalStateException
pmf
- PersistenceManagerFactory to create the session withallowCreate
- if a new PersistenceManager should be created if no thread-bound foundallowSynchronization
- if a new JDO PersistenceManager is supposed to be
registered with transaction synchronization (if synchronization is active).
This will always be true for typical data access code.
DataAccessResourceFailureException
- if the PersistenceManager couldn't be created
java.lang.IllegalStateException
- if no thread-bound PersistenceManager found and allowCreate falsepublic static void applyTransactionTimeout(javax.jdo.Query query, javax.jdo.PersistenceManagerFactory pmf, JdoDialect jdoDialect) throws javax.jdo.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)
javax.jdo.JDOException
JdoDialect.applyQueryTimeout(javax.jdo.Query, int)
public static DataAccessException convertJdoAccessException(javax.jdo.JDOException ex)
The most important cases like object not found or optimistic verification 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(javax.jdo.JDOException)
,
JdoTransactionManager.convertJdoAccessException(javax.jdo.JDOException)
,
JdoDialect.translateException(javax.jdo.JDOException)
public static void closePersistenceManagerIfNecessary(javax.jdo.PersistenceManager pm, javax.jdo.PersistenceManagerFactory pmf)
pm
- PersistenceManager to closepmf
- PersistenceManagerFactory that the PersistenceManager was created with
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |