These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: one-to-many relation - delete & insert error for child r
PostPosted: Sat Sep 03, 2005 6:43 am 
Newbie

Joined: Mon Oct 18, 2004 9:38 am
Posts: 5
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.