The Properties of a Persistence Manager


The persistence manager has five properties. Two of them, the PersistenceManagerFactory property and the Closed property, are read-only and are described at the beginning of this chapter. The other three properties are read-write.

The IgnoreCache Property

The PersistenceManager interface provides getter and setter methods for the IgnoreCache property.

 public boolean getIgnoreCache() public void setIgnoreCache(boolean icFlag) 

The IgnoreCache property determines whether JDO uses the persistent-new and persistent-deleted objects within the persistence manager's cache when iterating an extent. The setting of the IgnoreCache property at the time that the iterator is obtained determines the iterator's behavior. If the IgnoreCache property is true, then it is a hint to the JDO implementation to ignore during the iteration the deletions and insertions made within the currently active transaction. If the IgnoreCache property is false, then the iteration must include the persistent-new objects and exclude the persistent-deleted objects. This property has no effect on iterations that occur outside a transaction.

All changes committed prior to obtaining the iteration are automatically included in the iteration unless they are hidden by the datastore's isolation level. It is implementation dependent whether transactions, in other persistence managers, that commit after the iterator is obtained are visible in the iteration. The JDO implementation and the datastores that it targets define the isolation level of the transactions.

The setting of the IgnoreCache property is inherited by the IgnoreCache property in the Query objects that the persistence manager produces.

The Multithreaded Property

The PersistenceManager interface provides getter and setter methods for the Multithreaded property.

 public boolean getMultithreaded() public void setMultithreaded(boolean mtFlag) 

The JDO specification requires that its implementations be thread-safe. Applications may allow multiple, concurrently executing threads to use the same data object or the same persistence manager. JDO is responsible for ensuring that the persistence service, whether invoked explicitly or implicitly, is thread-safe, and for doing this in a way that does not cause deadlock with any synchronization locks that the application might use for its own purposes. To be thread-safe, JDO implementations synchronize on objects that are not visible to the application. Since synchronization is somewhat expensive for performance and since multithreaded use is not always required, the application can inform JDO that only one thread at a time will use the same data object or the same persistence manager. The application does this by setting the Multithreaded property to false. Setting the Multithreaded property to false is a hint for the JDO implementation that it may disregard. On the other hand, the JDO implementation may take the hint and avoid synchronization to improve performance.

The Multithreaded property is not a fine-grained property that should be flicked on and off. To avoid problems, pick a setting and stick to it.

The UserObject Property

The PersistenceManager interface provides getter and setter methods for the UserObject property.

 public Object getUserObject() public void setUserObject(Object userObject) 

The read-write UserObject property allows the application to associate any object with the persistence manager. JDO makes no use of this property, and applications can ignore it.




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