This continues a discussion on the JBoss Cache forum:
http://jboss.org/index.html?module=bb&o ... c&t=103983
Hibernate version:3.2.2
JBoss Cache version:1.4.1.SP2
Mapping:
Code:
@Entity
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
public class C {
@Id
int id;
}
Code between sessionFactory.openSession() and session.close() + a bit more:Code:
SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();
TransactionManager txManager = DummyTransactionManager.getInstance();
txManager.begin();
Session session = factory.getCurrentSession();
session.createQuery("update C c set c.id = 1").executeUpdate();
txManager.commit();
Full stack trace of any exception that occurs:Code:
org.hibernate.cache.CacheException: org.jboss.cache.CacheException: Must be in a valid transaction _remove; id:5(null, /com/medq/test/C, true)
at org.hibernate.cache.OptimisticTreeCache.clear(OptimisticTreeCache.java:169)
at org.hibernate.cache.TransactionalCache.clear(TransactionalCache.java:124)
at org.hibernate.impl.SessionFactoryImpl.evictEntity(SessionFactoryImpl.java:832)
at org.hibernate.action.BulkOperationCleanupAction.evictEntityRegions(BulkOperationCleanupAction.java:132)
at org.hibernate.action.BulkOperationCleanupAction.afterTransactionCompletion(BulkOperationCleanupAction.java:111)
at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:170)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:424)
at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:225)
at org.hibernate.transaction.CacheSynchronization.afterCompletion(CacheSynchronization.java:85)
at org.jboss.cache.transaction.DummyTransaction.notifyAfterCompletion(DummyTransaction.java:270)
at org.jboss.cache.transaction.DummyTransaction.commit(DummyTransaction.java:64)
at org.jboss.cache.transaction.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:61)
at com.medq.test.TestHibernate.main(TestHibernate.java:24)
Caused by: org.jboss.cache.CacheException: Must be in a valid transaction _remove; id:5(null, /com/medq/test/C, true)
at org.jboss.cache.interceptors.OptimisticNodeInterceptor.invoke(OptimisticNodeInterceptor.java:66)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.EvictionInterceptor.invoke(EvictionInterceptor.java:88)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor.invoke(OptimisticCreateIfNotExistsInterceptor.java:69)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.invoke(OptimisticValidatorInterceptor.java:84)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.OptimisticLockingInterceptor.invoke(OptimisticLockingInterceptor.java:126)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.OptimisticReplicationInterceptor.invoke(OptimisticReplicationInterceptor.java:147)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:365)
at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:160)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:183)
at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:5776)
at org.jboss.cache.TreeCache.remove(TreeCache.java:3855)
at org.jboss.cache.TreeCache.remove(TreeCache.java:3438)
at org.hibernate.cache.OptimisticTreeCache.clear(OptimisticTreeCache.java:166)
... 12 more
Name and version of the database you are using:Affects all databases.
The generated SQL (show_sql=true):Code:
Hibernate: update C set id=1