I am trying to provide a Spring compatible layer that works with Hibernate Shards and I have it mostly working. I keep running into the error where the TransactionSynchronizationManager.unbind is being called twice, but bind is being called once. Here is the partial stack trace:
java.lang.IllegalStateException: No value for key [org.hibernate.shards.session.ShardedSessionFactory Impl@644ca6b6] bound to thread [main]
at org.springframework.transaction.support.Transactio nSynchronizationManager.unbindResource(Transaction SynchronizationManager.java:184)
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCleanupAfterCompletion(HibernateTra nsactionManager.java:647)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.cleanupAfterCompletion(Ab stractPlatformTransactionManager.java:966)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:759)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:678)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:319)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:116)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:635)
at com.reardencommerce.kernel.shards.res.repository.S hardTestRepository$$EnhancerByCGLIB$$2a0f4f34.save ShardEntity(<generated>)
The first unbind removes the map. Does anyone know why it is being called twice? I have the method boolean isSameConnectionForEntireSession(Session session) return false since shards does not support the getCurrentSession(). It throws UnsupportedOperationException()


Reply With Quote