A common procedure for a Web or enterprise application is "detaching" objects from all server resources, modifying them, and then "attaching" them again. For example, a Web application might store persistent data in a user session during a modification based on a series of Web forms. Between each form request, the Web container might serialize the session, requiring that the stored persistent state be disassociated from any other resources.
Similarly, a client/server or EJB application might transfer persistent objects to a client via serialization, allow the client to modify their state, and then have the client return the modified data in order to be saved. This is sometimes referred to as the data transfer object pattern, and it allows fine-grained manipulation of data objects without incurring the performance overhead of multiple remote method invocations.
JDO 2.0 directly supports these scenarios with the new attach and detach APIs, which make using JDO in Web, client/server, and EJB applications significantly easier. The detachment capability eliminates yet another piece of infrastructure coding for JDO developers. Developers will be able to use their JDO instances as data transfer objects, eliminating the need to perform a mapping from JDO instances to data transfer instances.
Architects who prefer to use their own data transfer objects also benefit, as this new capability automates transactional consistency checking across a business transaction that might span multiple JDO transactions.
JDO Query Language Improvements
One of the biggest knocks on the JDO 1.0 specification was its lack of aggregate support in JDO Query Language (JDOQL). Aggregates include things like sum, min, max, average, count, etc. JDO 2.0 adds aggregate support to JDOQL. Additionally, JDOQL's support for various string-related methods and math functions will improve.
JDO 2.0 also offers named query support, providing a standardized mechanism for statically defining queries. This benefits enterprise users who want a simple way to ensure that all their non-dynamic queries are valid at deploy time.
JDO vendors previously supported this functionality only through proprietary extensions. Customers considering JDO can take comfort in knowing that these basic reporting functions will be available in a standard manner with the 2.0 spec.