org.springframework.orm.jdo
Interface JdoOperations

All Known Implementing Classes:
JdoTemplate

public interface JdoOperations

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

Provides JdoTemplate's data access methods that mirror various PersistenceManager methods. See the JDO PersistenceManager javadocs for details on those methods.

Note that lazy loading will just work with an open JDO PersistenceManager, either within a Spring-driven transaction (with JdoTransactionManager or JtaTransactionManager) or within OpenPersistenceManagerInViewFilter/Interceptor. Furthermore, some operations just make sense within transactions, for example: evict, evictAll, flush.

Since:
1.1
Author:
Juergen Hoeller
See Also:
JdoTemplate, PersistenceManager, JdoTransactionManager, JtaTransactionManager, OpenPersistenceManagerInViewFilter, OpenPersistenceManagerInViewInterceptor

Method Summary
 void deletePersistent(Object entity)
          Delete the given persistent instance.
 void deletePersistentAll(Collection entities)
          Delete all given persistent instances.
 void evict(Object entity)
          Remove the given object from the PersistenceManager cache.
 void evictAll()
          Remove all objects from the PersistenceManager cache.
 Object execute(JdoCallback action)
          Execute the action specified by the given action object within a PersistenceManager.
 Collection executeFind(JdoCallback action)
          Execute the specified action assuming that the result object is a Collection.
 Collection find(Class entityClass)
          Return all persistent instances of the given class.
 Collection find(Class entityClass, String filter)
          Return all persistent instances of the given class that match the given JDOQL filter.
 Collection find(Class entityClass, String filter, String ordering)
          Return all persistent instances of the given class that match the given JDOQL filter, with the given result ordering.
 Collection find(Class entityClass, String filter, String parameters, Map values)
          Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values.
 Collection find(Class entityClass, String filter, String parameters, Map values, String ordering)
          Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values, with the given result ordering.
 Collection find(Class entityClass, String filter, String parameters, Object[] values)
          Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values.
 Collection find(Class entityClass, String filter, String parameters, Object[] values, String ordering)
          Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values, with the given result ordering.
 void flush()
          Flush all transactional modifications to the database.
 Object getObjectById(Class entityClass, Serializable idValue)
          Return the persistent instance of the given entity class with the given id value, throwing an exception if not found.
 Object getObjectById(Serializable objectId)
          Return the persistent instance with the given JDO object id, throwing an exception if not found.
 void makePersistent(Object entity)
          Make the given transient instance persistent.
 void refresh(Object entity)
          Re-read the state of the given persistent instance.
 void refreshAll()
          Re-read the state of all persistent instances.
 

Method Detail

execute

public Object execute(JdoCallback action)
               throws DataAccessException
Execute the action specified by the given action object within a PersistenceManager. Application exceptions thrown by the action object get propagated to the caller (can only be unchecked). JDO 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 JdoTransactionManager.

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

executeFind

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

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

getObjectById

public Object getObjectById(Serializable objectId)
                     throws DataAccessException
Return the persistent instance with the given JDO object id, throwing an exception if not found.

A JDO object id identifies both the persistent class and the id within the namespace of that class.

Parameters:
objectId - a JDO object id of the persistent instance
Returns:
the persistent instance
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.getObjectById(java.lang.Object, boolean)

getObjectById

public Object getObjectById(Class entityClass,
                            Serializable 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. Its toString value must correspond to the toString value of the corresponding JDO object id.

Usually, the passed-in value will have originated from the primary key field of a persistent object that uses JDO's application identity.

Parameters:
entityClass - a persistent class
idValue - an id value of the persistent instance
Returns:
the persistent instance
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.getObjectById(java.lang.Object, boolean), PersistenceManager.newObjectIdInstance(java.lang.Class, java.lang.String)

evict

public void evict(Object entity)
           throws DataAccessException
Remove the given object from the PersistenceManager cache.

Parameters:
entity - the persistent instance to evict
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.evict(java.lang.Object)

evictAll

public void evictAll()
              throws DataAccessException
Remove all objects from the PersistenceManager cache.

Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.evictAll(java.lang.Object[])

refresh

public void refresh(Object entity)
             throws DataAccessException
Re-read the state of the given persistent instance.

Parameters:
entity - the persistent instance to re-read
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.refresh(java.lang.Object)

refreshAll

public void refreshAll()
                throws DataAccessException
Re-read the state of all persistent instances.

Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.refreshAll(java.lang.Object[])

makePersistent

public void makePersistent(Object entity)
                    throws DataAccessException
Make the given transient instance persistent.

Parameters:
entity - the transient instance to make persistent
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.makePersistent(java.lang.Object)

deletePersistent

public void deletePersistent(Object entity)
                      throws DataAccessException
Delete the given persistent instance.

Parameters:
entity - the persistent instance to delete
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.deletePersistent(java.lang.Object)

deletePersistentAll

public void deletePersistentAll(Collection entities)
                         throws DataAccessException
Delete all given persistent instances.

This can be combined with any of the find methods to delete by query in two lines of code.

Parameters:
entities - the persistent instances to delete
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.deletePersistentAll(java.lang.Object[])

flush

public void flush()
           throws DataAccessException
Flush all transactional modifications to the database.

Only invoke this for selective eager flushing, for example when JDBC code needs to see certain changes within the same transaction. Else, it's preferable to rely on auto-flushing at transaction completion.

Throws:
DataAccessException - in case of JDO errors
See Also:
JdoDialect.flush(javax.jdo.PersistenceManager)

find

public Collection find(Class entityClass)
                throws DataAccessException
Return all persistent instances of the given class.

Parameters:
entityClass - a persistent class
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class)

find

public Collection find(Class entityClass,
                       String filter)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match (or null if none)
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String)

find

public Collection find(Class entityClass,
                       String filter,
                       String ordering)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter, with the given result ordering.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match (or null if none)
ordering - the ordering of the result (or null if none)
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String), Query.setOrdering(java.lang.String)

find

public Collection find(Class entityClass,
                       String filter,
                       String parameters,
                       Object[] values)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match
parameters - the JDOQL parameter declarations
values - the corresponding parameter values
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String), Query.declareParameters(java.lang.String), Query.executeWithArray(java.lang.Object[])

find

public Collection find(Class entityClass,
                       String filter,
                       String parameters,
                       Object[] values,
                       String ordering)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values, with the given result ordering.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match
parameters - the JDOQL parameter declarations
values - the corresponding parameter values
ordering - the ordering of the result (or null if none)
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String), Query.declareParameters(java.lang.String), Query.executeWithArray(java.lang.Object[]), Query.setOrdering(java.lang.String)

find

public Collection find(Class entityClass,
                       String filter,
                       String parameters,
                       Map values)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match
parameters - the JDOQL parameter declarations
values - a Map with parameter names as keys and parameter values
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String), Query.declareParameters(java.lang.String), Query.executeWithMap(java.util.Map)

find

public Collection find(Class entityClass,
                       String filter,
                       String parameters,
                       Map values,
                       String ordering)
                throws DataAccessException
Return all persistent instances of the given class that match the given JDOQL filter, using the given parameter declarations and parameter values, with the given result ordering.

Parameters:
entityClass - a persistent class
filter - the JDOQL filter to match
parameters - the JDOQL parameter declarations
values - a Map with parameter names as keys and parameter values
ordering - the ordering of the result (or null if none)
Returns:
the persistent instances
Throws:
DataAccessException - in case of JDO errors
See Also:
PersistenceManager.newQuery(Class, String), Query.declareParameters(java.lang.String), Query.executeWithMap(java.util.Map), Query.setOrdering(java.lang.String)


Copyright (C) 2003-2004 The Spring Framework Project.