-->
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.  [ 2 posts ] 
Author Message
 Post subject: Editing an existing ID without generator
PostPosted: Tue Jun 05, 2007 8:54 am 
Beginner
Beginner

Joined: Tue May 08, 2007 8:26 am
Posts: 21
Hello I have a small problem.

I got a table in my database that contains an ID which is manually assigned (it is inserted through a form id input field that a user types).

Now I want to change this ID but Hibernate does not want to update the id attached to the object.

I assume this is because Hibernate does not know what the old ID was (or is there some property in the mapping files to enable this?), is there any way to edit an existing ID into a new one without removing the entire record and reinserting it with the new id ?

Thanks (my mapping is just a standard <id> without a generator)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 9:20 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
No there is not. If you change a primary key, you are essentially inserting a new object into your database. Hibernate enforces that principle by not allowing you to change primary keys.

Best bet is to re-insert it with your new primary key and delete the old entry.

_________________
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.  [ 2 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.