站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

JdoCallback (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.orm.jdo
Interface JdoCallback


public interface JdoCallback

Callback interface for JDO code. To be used with JdoTemplate's execute method, assumably often as anonymous classes within a method implementation. The typical implementation will call PersistenceManager CRUD to perform some operations on persistent objects.

Note that JDO works on bytecode-modified Java objects, to be able to perform dirty detection on each modification of a persistent instance field. In contrast to Hibernate, using returned objects outside of an active PersistenceManager poses a problem: To be able to read and modify fields e.g. in a web GUI, one has to explicitly make the instances "transient". Reassociation with a new PersistenceManager, e.g. for updates when coming back from the GUI, isn't possible, as the JDO instances have lost their identity when turned transient. This means that either value objects have to be used as parameters, or the contents of the outside-modified instance have to be copied to a freshly loaded active instance on reassociation.

Since:
03.06.2003
Author:
Juergen Hoeller
See Also:
JdoTemplate, HibernateCallback

Method Summary
 Object doInJdo(javax.jdo.PersistenceManager pm)
          Gets called by JdoTemplate.execute with an active PersistenceManager.
 

Method Detail

doInJdo

Object doInJdo(javax.jdo.PersistenceManager pm)
               throws javax.jdo.JDOException
Gets called by JdoTemplate.execute with an active PersistenceManager. Does not need to care about activating or closing the PersistenceManager, or handling transactions.

Note that JDO callback code will not flush any modifications to the database if not executed within a transaction. Thus, you need to make sure that JdoTransactionManager has initiated a JDO transaction when the callback gets called, at least if you want to write to the database.

Allows for returning a result object created within the callback, i.e. a domain object or a collection of domain objects. A thrown RuntimeException is treated as application exception, it gets propagated to the caller of the template.

Parameters:
pm - active PersistenceManager
Returns:
a result object, or null if none
Throws:
javax.jdo.JDOException - in case of JDO errors
See Also:
JdoTemplate.execute(org.springframework.orm.jdo.JdoCallback), JdoTransactionManager


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