|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.ojb.support.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 closePersistenceBrokerIfNecessary
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)
,
closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker)
,
PersistenceBrokerTemplate
Field Summary | |
protected Log |
logger
|
Constructor Summary | |
PersistenceBrokerDaoSupport()
|
Method Summary | |
void |
afterPropertiesSet()
|
protected void |
closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb)
Close the given PersistenceBroker if it isn't bound to the thread. |
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 |
initDao()
Subclasses can override this for custom initialization behavior. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Log logger
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()
public final void afterPropertiesSet() throws Exception
Exception
protected void initDao() throws Exception
Exception
- if initialization failsprotected final org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(boolean allowCreate) throws DataAccessResourceFailureException, IllegalStateException
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)
pb
- PersistenceBroker to close
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |