-->
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.  [ 3 posts ] 
Author Message
 Post subject: Modifying Composite Key
PostPosted: Fri Jul 07, 2006 5:31 am 
Newbie

Joined: Fri Jul 07, 2006 5:17 am
Posts: 2
Hi,

This is Jagadish. I have a composite key of 3 columns in mysql database table. I am connecting to the database through hibernate. I am trying to update a row in the table after modifying one of the column in the composite key.

But i am getting the following exception "Could not synchronize database state with session". Can anyone help me.

Regards,
Jagadish


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 8:45 am 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
Try and update it using plain HQL or an update query as a named query.....

Dont try to update a key of row, by reading that row from db and then using session.update()

Sudhir


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 10:28 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
You cannot update the composite key through standard hibernate loads, updates and stuff because changing the key is essentially making a new object/row.

Either delete the old object and make a new one with the new value in the composite key, or like the guy above said, use direct sql to update it. Session.createSqlQuery("update..."); outta do the trick.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.