org.springframework.orm.ojb
Interface PersistenceBrokerOperations

All Known Implementing Classes:
PersistenceBrokerTemplate

public interface PersistenceBrokerOperations

Interface that specifies a basic set of OJB PersistenceBroker operations. Implemented by PersistenceBrokerTemplate. Not often used, but a useful option to enhance testability, as it can easily be mocked or stubbed.

Provides PersistenceBrokerTemplate's data access methods that mirror various PersistenceBroker methods. See the OJB PersistenceBroker javadocs for details on those methods. Additionally, there is a convenient getObjectById method (Hibernate/JDO-style).

Note that operations that return an Iterator (that is, getIteratorByQuery and getReportQueryIteratorByQuery) are supposed to be used within Spring-managed transactions (with PersistenceBrokerTransactionManager or JtaTransactionManager). Else, the Iterator won't be able to read results from its ResultSet anymore, as the underlying PersistenceBroker will already have been closed.

Since:
1.1
Author:
Juergen Hoeller
See Also:
PersistenceBrokerTemplate, PersistenceBroker, getIteratorByQuery(org.apache.ojb.broker.query.Query), getReportQueryIteratorByQuery(org.apache.ojb.broker.query.Query), PersistenceBrokerTransactionManager, JtaTransactionManager

Method Summary
 void clearCache()
           
 void delete(Object entity)
           
 void deleteByQuery(org.apache.ojb.broker.query.Query query)
           
 Object execute(PersistenceBrokerCallback action)
          Execute the action specified by the given action object within a PersistenceBroker.
 Collection executeFind(PersistenceBrokerCallback action)
          Execute the specified action assuming that the result object is a Collection.
 Collection getCollectionByQuery(org.apache.ojb.broker.query.Query query)
           
 int getCount(org.apache.ojb.broker.query.Query query)
           
 Iterator getIteratorByQuery(org.apache.ojb.broker.query.Query query)
           
 Object getObjectById(Class entityClass, Object idValue)
          Return the persistent instance of the given entity class with the given id value, throwing an exception if not found.
 Object getObjectByQuery(org.apache.ojb.broker.query.Query query)
           
 Iterator getReportQueryIteratorByQuery(org.apache.ojb.broker.query.Query query)
           
 void removeFromCache(Object entityOrId)
           
 void store(Object entity)
           
 

Method Detail

execute

Object execute(PersistenceBrokerCallback action)
               throws DataAccessException
Execute the action specified by the given action object within a PersistenceBroker. Application exceptions thrown by the action object get propagated to the caller (can only be unchecked). OJB exceptions are transformed into appropriate DAO ones. Allows for returning a result object, i.e. a domain object or a collection of domain objects.

Note: Callback code is not supposed to handle transactions itself! Use an appropriate transaction manager like PersistenceBrokerTransactionManager.

Parameters:
action - action object that specifies the OJB action
Returns:
a result object returned by the action, or null
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBrokerTransactionManager, org.springframework.dao, org.springframework.transaction

executeFind

Collection executeFind(PersistenceBrokerCallback action)
                       throws DataAccessException
Execute the specified action assuming that the result object is a Collection. This is a convenience method for executing OJB queries within an action.

Parameters:
action - action object that specifies the OJB action
Returns:
a result object returned by the action, or null
Throws:
DataAccessException - in case of OJB errors

getObjectById

Object getObjectById(Class entityClass,
                     Object idValue)
                     throws DataAccessException
Return the persistent instance of the given entity class with the given id value, throwing an exception if not found.

The given id value is typically just unique within the namespace of the persistent class, corresponding to a single primary key in a database table.

Parameters:
entityClass - a persistent class
idValue - an id value of the persistent instance
Returns:
the persistent instance
Throws:
ObjectRetrievalFailureException - if not found
DataAccessException - in case of OJB errors
See Also:
IdentityFactory.buildIdentity(Class, Object), PersistenceBroker.getObjectByIdentity(org.apache.ojb.broker.Identity)

getObjectByQuery

Object getObjectByQuery(org.apache.ojb.broker.query.Query query)
                        throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.getObjectByQuery(org.apache.ojb.broker.query.Query)

getCollectionByQuery

Collection getCollectionByQuery(org.apache.ojb.broker.query.Query query)
                                throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.getCollectionByQuery(org.apache.ojb.broker.query.Query)

getIteratorByQuery

Iterator getIteratorByQuery(org.apache.ojb.broker.query.Query query)
                            throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.getIteratorByQuery(org.apache.ojb.broker.query.Query)

getReportQueryIteratorByQuery

Iterator getReportQueryIteratorByQuery(org.apache.ojb.broker.query.Query query)
                                       throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.getReportQueryIteratorByQuery(org.apache.ojb.broker.query.Query)

getCount

int getCount(org.apache.ojb.broker.query.Query query)
             throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.getCount(org.apache.ojb.broker.query.Query)

removeFromCache

void removeFromCache(Object entityOrId)
                     throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.removeFromCache(java.lang.Object)

clearCache

void clearCache()
                throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.clearCache()

store

void store(Object entity)
           throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.store(java.lang.Object, org.apache.ojb.broker.util.ObjectModification)

delete

void delete(Object entity)
            throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.delete(java.lang.Object)

deleteByQuery

void deleteByQuery(org.apache.ojb.broker.query.Query query)
                   throws DataAccessException
Throws:
DataAccessException - in case of OJB errors
See Also:
PersistenceBroker.deleteByQuery(org.apache.ojb.broker.query.Query)


Copyright (c) 2002-2007 The Spring Framework Project.