Hey guys--
I'm seeing a problem with inconsistent object data across contexts using a
shared cache and am hoping someone can shed some light for me.
I've got a situation where 2 threads (each with its own context) winds up
interacting with the same persistent object.
The first thread updates the object's status, as seen in this log:
2009-08-13 14:47:08,492 INFO [org.apache.cayenne.access.QueryLogger] -
<UPDATE ORDER_ITEM_STATUS SET LAST_UPDATED = ?, ITEM_STATUS = ?,
TRANSFERRED_LENGTH = ? WHERE ID = ?>
2009-08-13 14:47:08,492 INFO [org.apache.cayenne.access.QueryLogger] -
<[bind: 1->LAST_UPDATED:'2009-08-13 14:47:08.492',
2->ITEM_STATUS:'COMPLETED', 3->TRANSFERRED_LENGTH:15142272, 4->ID:3906]>
2009-08-13 14:47:08,492 INFO [org.apache.cayenne.access.QueryLogger] - <===
updated 1 row.>
2009-08-13 14:47:08,492 INFO [org.apache.cayenne.access.QueryLogger] - <+++
transaction committed.>
Moments later, a different thread operating on some related objects does
some status checking via a postUpdate event.
for (OrderItemStatus testStatus : statusColl) {
*testStatus =
(OrderItemStatus)DataObjectUtils.objectForPK(ctx, testStatus.getObjectId());
*
log.debug("\tChecking item status " +
testStatus.getId() + ": " + testStatus.getDistributionStatus());
Which produces the log:
2009-08-13 14:47:09,070 DEBUG
[com.routeto1.order.OrderItemStatusDataListener] - < Checking item status
3906: QUEUED>
This second debug statement shows that the item status with ID 3906 is
showing as QUEUED, even though I had updated the status to COMPLETED just
before.
I thought I had this stale data problem covered.. my understanding is that
the objectForPK method would refresh the object from shared cache.. but it
doesn't appear to be doing so, or else the shared cache has somehow been
replaced with a stale object.
Am I misunderstanding something? Is there something I am doing wrong?
Using 3.0 M5 FYI. The cache config is completely default.. shared cache
enabled, 10000 max.. so no config shows up in the cayenne.xml file.
Thanks for any guidance you can provide--
Dave
This archive was generated by hypermail 2.0.0 : Thu Aug 13 2009 - 18:10:59 EDT