stliu/hibernate-core — comment on commit 1b5d98ea900d7b34b20a24900224d5c056505a66
File: hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadWriteCollectionRegionAccessStrategy.java line 63
By stliu:

okay, maybe override this method is incorrect
the reason _org.hibernate.ejb.test.EntityManagerTest#testConfiguration_ fails w/o this override is this:

in the first persist section, _CollectionAction_ does the following

1. lockItem org.hibernate.action.internal.CollectionAction#beforeExecutions
this put a Lock into the collection cache region

2. evict org.hibernate.action.internal.CollectionAction#evict
now, the Lock got removed
3. unlockItem org.hibernate.action.internal.CollectionAction.CacheCleanupProcess#doAfterTransactionCompletion
since the Lock was removed from region, then the unlockItem fails into org.hibernate.testing.cache.AbstractReadWriteAccessStrategy#handleLockExpiry, which create a new Lock (with new timestamp + timeout)

then in the first `find Item second = em.find( Item.class, item.getName() );`, this is supposed to put the queried collection data into cache region, but in cache, it is a Lock with new timestamp + timeout, so, when the put happens (see `org.hibernate.testing.cache.AbstractReadWriteAccessStrategy#putFromLoad`), it first compare the timestamp to check if the cache item is writable, and fail (the new created session's timestamp < timestamp create in #3 + timeout)

then this cache putfromLoad is ignored, and in the second `find`, there is no more 2L cache hit, so the actual 2L cache hit is 2 but expect 2L cache hit is 3