Hi All,
I am using Hibernate3 with springframework-1.2.3
When I try to delete a record which doesn't exists with the following code I get the following exception:
getHibernateTemplate().delete(authority);
Hibernate: delete from MATRIX.LSWDEV.LWAUTH where AUAUTH=?
23-Nov-2005 18:12:12 org.hibernate.event.def.AbstractFlushingEventListe ner performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.HibernateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(N onBatchingBatcher.java:33)
at org.hibernate.persister.entity.AbstractEntityPersi ster.delete(AbstractEntityPersister.java:2290)
at org.hibernate.persister.entity.AbstractEntityPersi ster.delete(AbstractEntityPersister.java:2439)
at org.hibernate.action.EntityDeleteAction.execute(En tityDeleteAction.java:65)
at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:145)
at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:296)
at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:905)
at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:345)
at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:490)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:495)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:468)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:258)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:606)
at com.bertrams.bls.delegate.UserManagementDelegate$$ EnhancerByCGLIB$$5099978f.deleteAuthority(<generat ed>)
at com.bertrams.bls.config.test.entity.TestUserDB.tes tCreateUser(TestUserDB.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at junit.framework.TestCase.runTest(TestCase.java:154 )
at junit.framework.TestCase.runBare(TestCase.java:127 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:192)
However if I try to delete as below it is working:
Session s = getHibernateTemplate().getSessionFactory().openSes sion();
s.delete(authority);
Any ideas what I am doing wrong?


Reply With Quote
, but this might help 