org.springframework.orm.jdo.support
abstract public class: JdoDaoSupport [javadoc |
source]
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.orm.jdo.support.JdoDaoSupport
All Implemented Interfaces:
InitializingBean
Convenient super class for JDO data access objects.
Requires a PersistenceManagerFactory to be set, providing a JdoTemplate
based on it to subclasses. Can alternatively be initialized directly with a
JdoTemplate, to reuse the latter's settings such as the PersistenceManagerFactory,
JdoDialect, flush mode, etc.
This base class is mainly intended for JdoTemplate usage but can also
be used when working with PersistenceManagerFactoryUtils directly, for example
in combination with JdoInterceptor-managed PersistenceManagers. Convenience
getPersistenceManager and releasePersistenceManager
methods are provided for that usage style.
This class will create its own JdoTemplate if only a PersistenceManagerFactory
is passed in. The "allowCreate" flag on that JdoTemplate will be "true" by default.
A custom JdoTemplate instance can be used through overriding createJdoTemplate.
| Method from org.springframework.orm.jdo.support.JdoDaoSupport Detail: |
protected final void checkDaoConfig() {
if (this.jdoTemplate == null) {
throw new IllegalArgumentException("persistenceManagerFactory or jdoTemplate is required");
}
}
|
protected final DataAccessException convertJdoAccessException(JDOException ex) {
return this.jdoTemplate.convertJdoAccessException(ex);
}
|
protected JdoTemplate createJdoTemplate(PersistenceManagerFactory persistenceManagerFactory) {
return new JdoTemplate(persistenceManagerFactory);
}
Create a JdoTemplate for the given PersistenceManagerFactory.
Only invoked if populating the DAO with a PersistenceManagerFactory reference!
Can be overridden in subclasses to provide a JdoTemplate instance
with different configuration, or a custom JdoTemplate subclass. |
public final JdoTemplate getJdoTemplate() {
return jdoTemplate;
}
Return the JdoTemplate for this DAO, pre-initialized
with the PersistenceManagerFactory or set explicitly. |
protected final PersistenceManager getPersistenceManager() {
return getPersistenceManager(this.jdoTemplate.isAllowCreate());
}
Get a JDO PersistenceManager, either from the current transaction or
a new one. The latter is only allowed if the "allowCreate" setting
of this bean's JdoTemplate is true. |
protected final PersistenceManager getPersistenceManager(boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException {
return PersistenceManagerFactoryUtils.getPersistenceManager(getPersistenceManagerFactory(), allowCreate);
}
Get a JDO PersistenceManager, either from the current transaction or
a new one. The latter is only allowed if "allowCreate" is true. |
public final PersistenceManagerFactory getPersistenceManagerFactory() {
return (this.jdoTemplate != null ? this.jdoTemplate.getPersistenceManagerFactory() : null);
}
Return the JDO PersistenceManagerFactory used by this DAO. |
protected final void releasePersistenceManager(PersistenceManager pm) {
PersistenceManagerFactoryUtils.releasePersistenceManager(pm, getPersistenceManagerFactory());
}
Close the given JDO PersistenceManager, created via this DAO's
PersistenceManagerFactory, if it isn't bound to the thread. |
public final void setJdoTemplate(JdoTemplate jdoTemplate) {
this.jdoTemplate = jdoTemplate;
}
Set the JdoTemplate for this DAO explicitly,
as an alternative to specifying a PersistenceManagerFactory. |
public final void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory) {
if (this.jdoTemplate == null || persistenceManagerFactory != this.jdoTemplate.getPersistenceManagerFactory()) {
this.jdoTemplate = createJdoTemplate(persistenceManagerFactory);
}
}
Set the JDO PersistenceManagerFactory to be used by this DAO.
Will automatically create a JdoTemplate for the given PersistenceManagerFactory. |