14.2 Performance Optimizations


JDO provides two simple ways to optimize application performance. The first is the concept of the "default fetch group ," and the second are the retrieveAll() methods on PersistenceManager .

The default fetch group allows an application to determine the set of fields that should be retrieved from the datastore by default whenever an instance of a particular persistence-capable class is retrieved. By putting commonly accessed fields into the default fetch group, they will all be retrieved in a single datastore operation. In addition, less commonly accessed fields are then retrieved only when needed.

The retrieveAll() methods allow an application to retrieve a group of persistent objects potentially in a single datastore request and to avoid a single request per persistent object. This is particularly useful when iterating through the result of a query.

Beyond these two simple optimizations, JDO 2.0 may introduce a mechanism that allows an application to define policies that will govern the retrieval of graphs of persistent objects automatically. These policies may range from simple closure operations (retrieve all reachable persistent objects from a given persistent object) to more selective operations that would retrieve persistent objects reachable via certain fields, or up to a certain depth, or of a particular class only. Some JDO implementations already offer proprietary support for this feature.

The benefit of being able to specify retrieve policies in this way is that it allows optimization of datastore access without the need for additional coding. Different applications, or even different transactions within the same application, could specify different policies, depending on the application logic being performed at the time.



Core Java Data Objects
Core Java Data Objects
ISBN: 0131407317
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net