This issue isn't reproducible neither with CacheConcurrencyStrategy.NONSTRICT_READ_WRITE not with CacheConcurrencyStrategy.READ_WRITE in Hibernate 3.6.0, since org.hibernate.engine.TwoPhaseLoad is more smart in 3.6.0; I was working on 3.3.1.GA previously
Hibernate 3.3.1.GA
boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
session.getTimestamp(),
version,
useMinimalPuts( session, entityEntry )
);
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
}
Hibernate 3.6.0
// explicit handling of caching for rows just inserted and then somehow forced to be read
// from the database *within the same transaction*. usually this is done by
// 1) Session#refresh, or
// 2) Session#clear + some form of load
//
// we need to be careful not to clobber the lock here in the cache so that it can be rolled back if need be
if ( session.getPersistenceContext().wasInsertedDuringTransaction( persister, id ) ) {
persister.getCacheAccessStrategy().update(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
version,
version
);
}
else {
boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
session.getTimestamp(),
version,
useMinimalPuts( session, entityEntry )
);
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
}
}
It's still a problem for CacheConcurrencyStrategy.TRANSACTIONAL at least when using local transactions (Spring in my case), but I guess it can be solved if using cache as a XA resource in JTA environment (for example ehcache can be configured as XA resource)
This issue isn't reproducible neither with CacheConcurrencyStrategy.NONSTRICT_READ_WRITE not with CacheConcurrencyStrategy.READ_WRITE in Hibernate 3.6.0, since org.hibernate.engine.TwoPhaseLoad is more smart in 3.6.0; I was working on 3.3.1.GA previously
It's still a problem for CacheConcurrencyStrategy.TRANSACTIONAL at least when using local transactions (Spring in my case), but I guess it can be solved if using cache as a XA resource in JTA environment (for example ehcache can be configured as XA resource)
Probably this issue can be closed now