Hibernate version:2.x
Mapping documents:<set name="userExpertiseList" cascade="all-delete-orphan" inverse="true" lazy="false"> <key column="UserID"/> <one-to-many class="UserExpertise"/> </set>
Full stack trace of any exception that occurs: [SessionImpl] Could not synchronize database state with sessi on net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row no t found) at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatche r.java:25) at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.jav a:595) at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.jav a:29) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2422) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2380) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2244) at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j ava:61) at com.coreobjects.ccc.dataaccess.provider.hibernate.HibernateTransactio n.commitTransaction(HibernateTransaction.java:28) at com.coreobjects.ccc.dataaccess.Txn.commit(Txn.java:32) at com.friendlyanswers.server.user.UserManagerImpl.updateUser(UserManage rImpl.java:494) at com.friendlyanswers.web.UserBean.updateProfile(UserBean.java:671) at com.friendlyanswers.web.FAServlet.updateProfile(FAServlet.java:581)
The generated SQL (show_sql=true):delete from UserExpertise where expertiseId=?
1. I have a User table that has a child table UserExpertise, to store one to many records for each of the user
2. As part of update user on our website the UserExpertise is selected again by the user, so as part of the code.. I'm clearing the UserExpertiseList in the User object and updating the user
3. Because we are clearing and putting new UserExpertise to the user object, hibernate generate a delete UserExpertise query as shown above & later generates a insert statement
4. Now at this delete statement, I get the error as pasted above. Any idea why this could be happening? is my mapping wrong? or my procedure to clear the list and add new user expertise incorrect?
5. NOTE: I have to keep the lazy="false" on the child as we have client application that downloads the user object & at that point I would like to download the complete user object to the application.
Any thoughts to resolve this would really helpful...
Thanks
Bhaskar
|