-->
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.  [ 6 posts ] 
Author Message
 Post subject: Updating primary key
PostPosted: Mon Dec 11, 2006 9:53 am 
Newbie

Joined: Thu Jun 09, 2005 7:12 am
Posts: 7
Hibernate version: 3.0


Is it possible to update the primary key of a table using Hibernate? Specifically, can one update a composite key of a child using the parent object in a <one-to-many> mapping?

If yes, can someone please direct me to the correct place in the ref manual (I've tried in vain) or somewhere else ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 10:38 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
hibernte does not allow you to update primary keys.

It is best to delete the old child and create a new one with a new primary key.

_________________
Chris

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 10:47 am 
Beginner
Beginner

Joined: Thu Oct 12, 2006 6:19 pm
Posts: 34
Location: Guatemala
Hi devu, it already was discussed before. Based in relational theory the primary key could not be changed, it is for definition, maybe you must consider to delete an object and to create another.

_________________
God is Love


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 11:29 pm 
Newbie

Joined: Thu Jun 09, 2005 7:12 am
Posts: 7
Halcon,

Can you please direct me to the post or atleast the search string for it? My efforts to find the post (before posting mine) have been fruitless.

I might have missed it because I'm not a regular around here.


You're definitely making sense with regards the relational perspective.
But that's the way the datamodel (out of my hands) has been set up.

Here it is

TB_CALENDAR
=======
CAL_ID - PK


TB_CAL_DETLS
==========
CAL_ID - PK
CAL_DT - PK
DAY_TYPE_ID -PK
CREATED_BY
MODIFIED_BY

TB_CAL_DAY_TYPE
============
DAY_TYPE_ID - PK
DAY_TYPE_DESC

(for this table examples are 1- start of year, 2 - end of year and so on)

So in the table TB_CAL_DETLS, the user can change the date for start of the year and end of the year and so on.... which changes the primary key...

As for the reason, why it can't be deleted and re-inserted, that would lose the original CREATED_BY(unless its managed through code, which I am now considering) as all these updates happen through GUI and the original creator of the calendar and its modifier might be different people.




Thanks again,

Devu.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 2:30 am 
Newbie

Joined: Thu Jun 09, 2005 7:12 am
Posts: 7
Found it...

http://www.hibernate.org/117.html#A28

Looks like I'll have to manage it through code....

Thanks anyway...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 10:33 am 
Beginner
Beginner

Joined: Thu Oct 12, 2006 6:19 pm
Posts: 34
Location: Guatemala
Hi devu, sorry for my delayed reply, but I lost your post, I hope you have found the adequate response.

Bye

_________________
God is Love


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.