Chapter 4: Transactions and Caching


Overview

JDO provides a transactional persistence service for objects in memory. JDO identity links the managed object in memory to its corresponding persistent state in the datastore. JDO transactions define the semantics of synchronizing the persistent state in memory with the persistent state in the datastore. Each persistence manager controls the persistent state of some number of persistent objects. These objects and their persistent state are called the persistence manager's cache. For each object in the cache, JDO determines when to load its persistent state, when to discard its persistent state, and when to store its persistent state.

JDO provides performance benefits to the application that a datastore service, like JDBC, does not. When an application uses a datastore service, it creates, upon demand, objects in memory to hold persistent state in the datastore. Often, the objects in memory are simple value objects for the state in the datastore. When the application needs to fetch the persistent state again, a simple application usually creates another value object. More sophisticated applications avoid this behavior, but a good deal of code is required to implement a transactionally aware cache of persistent objects. JDO implementations already contain the code that manages the cache of persistent objects, tracks their transactional state, and lazily loads their persistent state. By using JDO, applications can see significant performance benefits.

JDO is designed to work in managed and unmanaged deployment environments. By satisfying the requirements of the J2EE Connector Architecture (JCA), JDO implementations accommodate containers that manage local and distributed transactions using the Java Transaction API (JTA). For example, an Enterprise JavaBean (EJB) that uses JDO can be deployed to use container-managed transactions (CMT). JDO also provides a simple way for applications to control their own transactions when distributed transactions or container-managed transactions are not used.

This chapter begins by defining transactions and examining the operations and properties of JDO's Transaction interface. It then examines how these properties control JDO's persistence service when it loads, discards, and stores persistent state. Next, it examines JDO's integration with JCA and JTA. The chapter concludes by identifying when JDO's caching is likely to improve performance and when it is not likely to improve performance.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

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