I'm using 1.0 rc1 with the PB API.  I'm noticing that I don't have any isolation 
between multiple brokers when caching is enabled.  For example:
 
  Object[] pk = new Object[] {new Long(42)};
  Identity id = new Identity(Article.class, pk);
  
  PersistenceBroker broker1 = PersistenceBrokerFactory.defaultPersistenceBroker();
  broker.beginTransaction();

  Article a1 = (Article) broker.getObjectByQuery(new QueryByIdentity(id));
  a1.articleName = "My article";
  
  // start a second transaction
  PersistenceBroker broker2 = PersistenceBrokerFactory.defaultPersistenceBroker();
  broker2.beginTransaction();

  Article a2 = (Article) broker.getObjectByQuery(new QueryByIdentity(id));
  // a2 is another reference to the same Article as a1
  a2.unit = "kg";

  broker2.abortTransaction();
  
  broker.store(a1, ObjectModificationDefaultImpl.UPDATE);
  broker.commitTransaction();
  
  broker2.close();   
  broker.close();
 
The changes that I made on the aborted broker2 transaction end up getting persisted on 
the broker1 transaction because they're sharing the same object reference.  Similarly 
changes made on other transactions are visible even before they're committed.  In 
general it doesn't look like I have any transactional isolation if caching is turned 
on.  I guess my gut expectation was that caches would be broker specific and there 
would be communication between caches to coordinate invalidations on updates and 
deletes.
 
So how do other people deal with this?  I had thought maybe I could manage two 
jdbc-connection-descriptors pointing to the same database, one with a cache used only 
for reads and another with caching turned off used for updates but it looks like the 
caching policy is global not on a per descriptor basis.  Am I missing something 
obvious?

Reply via email to