|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.dao.support.DaoSupport org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport
public abstract class PersistenceBrokerDaoSupport
Convenient super class for OJB PersistenceBroker data access objects.
Allows a JDBC Connection Descriptor alias to be set, providing a PersistenceBrokerTemplate based on it to subclasses. Can alternatively be initialized directly via a PersistenceBrokerTemplate, to reuse the latter's settings like PBKey, DataSource, etc.
This base class is mainly intended for PersistenceBrokerTemplate usage but
can also be used when working with OjbFactoryUtils directly. Convenience
getPersistenceBroker
and releasePersistenceBroker
methods are provided for that usage style.
This class will create its own PersistenceBrokerTemplate if no explicit
instance is passed in. The allowCreate flag on that PersistenceBrokerTemplate
will be true by default. A custom PersistenceBrokerTemplate instance can be
used through overriding createHibernateTemplate
.
setJcdAlias(java.lang.String)
,
setPersistenceBrokerTemplate(org.springframework.orm.ojb.PersistenceBrokerTemplate)
,
createPersistenceBrokerTemplate()
,
getPersistenceBroker(boolean)
,
releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker)
,
PersistenceBrokerTemplate
Field Summary |
---|
Fields inherited from class org.springframework.dao.support.DaoSupport |
---|
logger |
Constructor Summary | |
---|---|
PersistenceBrokerDaoSupport()
|
Method Summary | |
---|---|
protected void |
checkDaoConfig()
Abstract subclasses must override this to check their configuration. |
protected void |
closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb)
Deprecated. in favor of releasePersistenceBroker |
protected DataAccessException |
convertOjbAccessException(org.apache.ojb.broker.PersistenceBrokerException ex)
Convert the given PersistenceBrokerException to an appropriate exception from the org.springframework.dao hierarchy. |
protected PersistenceBrokerTemplate |
createPersistenceBrokerTemplate()
Create a new default PersistenceBrokerTemplate on initialization. |
String |
getJcdAlias()
Return the JDBC Connection Descriptor alias of the PersistenceBroker configuration to use. |
protected org.apache.ojb.broker.PersistenceBroker |
getPersistenceBroker(boolean allowCreate)
Get an OJB PersistenceBroker. |
PersistenceBrokerTemplate |
getPersistenceBrokerTemplate()
Return the PersistenceBrokerTemplate for this DAO, pre-initialized with the JCD alias or set explicitly. |
protected void |
releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker pb)
Close the given PersistenceBroker if it isn't bound to the thread. |
void |
setJcdAlias(String jcdAlias)
Set the JDBC Connection Descriptor alias of the PersistenceBroker configuration to use. |
void |
setPersistenceBrokerTemplate(PersistenceBrokerTemplate persistenceBrokerTemplate)
Set the PersistenceBrokerTemplate for this DAO explicitly, as an alternative to specifying a JCD alias. |
Methods inherited from class org.springframework.dao.support.DaoSupport |
---|
afterPropertiesSet, initDao |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PersistenceBrokerDaoSupport()
Method Detail |
---|
protected PersistenceBrokerTemplate createPersistenceBrokerTemplate()
Can be overridden in subclasses to provide a PersistenceBrokerTemplate instance with different configuration, or a custom PersistenceBrokerTemplate subclass.
setJcdAlias(java.lang.String)
,
setPersistenceBrokerTemplate(org.springframework.orm.ojb.PersistenceBrokerTemplate)
public final void setJcdAlias(String jcdAlias)
public final String getJcdAlias()
public final void setPersistenceBrokerTemplate(PersistenceBrokerTemplate persistenceBrokerTemplate)
public final PersistenceBrokerTemplate getPersistenceBrokerTemplate()
protected final void checkDaoConfig()
DaoSupport
Implementors should be marked as final
, to make it clear that
concrete subclasses are not supposed to override this template method themselves.
checkDaoConfig
in class DaoSupport
protected final org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException
allowCreate
- if a non-transactional PersistenceBroker should be created
when no transactional PersistenceBroker can be found for the current thread
DataAccessResourceFailureException
- if the PersistenceBroker couldn't be created
IllegalStateException
- if no thread-bound PersistenceBroker found and allowCreate falseprotected final DataAccessException convertOjbAccessException(org.apache.ojb.broker.PersistenceBrokerException ex)
ex
- PersistenceBrokerException that occured
OjbAccessor.convertOjbAccessException(org.apache.ojb.broker.PersistenceBrokerException)
protected final void closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb)
protected final void releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker pb)
pb
- PersistenceBroker to close
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |