public abstract class

JdoDaoSupport

extends DaoSupport
java.lang.Object
   ↳ org.springframework.dao.support.DaoSupport
     ↳ org.springframework.orm.jdo.support.JdoDaoSupport

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class org.springframework.dao.support.DaoSupport
Public Constructors
JdoDaoSupport()
Public Methods
final JdoTemplate getJdoTemplate()
Return the JdoTemplate for this DAO, pre-initialized with the PersistenceManagerFactory or set explicitly.
final PersistenceManagerFactory getPersistenceManagerFactory()
Return the JDO PersistenceManagerFactory used by this DAO.
final void setJdoTemplate(JdoTemplate jdoTemplate)
Set the JdoTemplate for this DAO explicitly, as an alternative to specifying a PersistenceManagerFactory.
final void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory)
Set the JDO PersistenceManagerFactory to be used by this DAO.
Protected Methods
final void checkDaoConfig()
Abstract subclasses must override this to check their configuration.
final DataAccessException convertJdoAccessException(JDOException ex)
Convert the given JDOException to an appropriate exception from the org.springframework.dao hierarchy.
JdoTemplate createJdoTemplate(PersistenceManagerFactory persistenceManagerFactory)
Create a JdoTemplate for the given PersistenceManagerFactory.
final PersistenceManager getPersistenceManager(boolean allowCreate)
Get a JDO PersistenceManager, either from the current transaction or a new one.
final PersistenceManager getPersistenceManager()
Get a JDO PersistenceManager, either from the current transaction or a new one.
final void releasePersistenceManager(PersistenceManager pm)
Close the given JDO PersistenceManager, created via this DAO's PersistenceManagerFactory, if it isn't bound to the thread.
[Expand]
Inherited Methods
From class org.springframework.dao.support.DaoSupport
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean

Public Constructors

public JdoDaoSupport ()

Public Methods

public final JdoTemplate getJdoTemplate ()

Return the JdoTemplate for this DAO, pre-initialized with the PersistenceManagerFactory or set explicitly.

public final PersistenceManagerFactory getPersistenceManagerFactory ()

Return the JDO PersistenceManagerFactory used by this DAO.

public final void setJdoTemplate (JdoTemplate jdoTemplate)

Set the JdoTemplate for this DAO explicitly, as an alternative to specifying a PersistenceManagerFactory.

public final void setPersistenceManagerFactory (PersistenceManagerFactory persistenceManagerFactory)

Set the JDO PersistenceManagerFactory to be used by this DAO. Will automatically create a JdoTemplate for the given PersistenceManagerFactory.

Protected Methods

protected final void checkDaoConfig ()

Abstract subclasses must override this to check their configuration.

Implementors should be marked as final

protected final DataAccessException convertJdoAccessException (JDOException ex)

Convert the given JDOException to an appropriate exception from the org.springframework.dao hierarchy.

Delegates to the convertJdoAccessException method of this DAO's JdoTemplate.

Parameters
ex JDOException that occured
Returns
  • the corresponding DataAccessException instance

protected JdoTemplate createJdoTemplate (PersistenceManagerFactory 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.

Parameters
persistenceManagerFactory the JDO PersistenceManagerFactoryto create a JdoTemplate for
Returns
  • the new JdoTemplate instance

protected final PersistenceManager getPersistenceManager (boolean allowCreate)

Get a JDO PersistenceManager, either from the current transaction or a new one. The latter is only allowed if "allowCreate" is true.

Parameters
allowCreate if a non-transactional PersistenceManager should be created when no transactional PersistenceManager can be found for the current thread
Returns
  • the JDO PersistenceManager
Throws
DataAccessResourceFailureException if the PersistenceManager couldn't be created
IllegalStateException if no thread-bound PersistenceManager found and allowCreate false

protected final PersistenceManager getPersistenceManager ()

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.

Returns
  • the JDO PersistenceManager
Throws
DataAccessResourceFailureException if the PersistenceManager couldn't be created
IllegalStateException if no thread-bound PersistenceManager found and allowCreate false

protected final void releasePersistenceManager (PersistenceManager pm)

Close the given JDO PersistenceManager, created via this DAO's PersistenceManagerFactory, if it isn't bound to the thread.

Parameters
pm PersistenceManager to close