-->
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: Extending a persisted superclass while keeping same ID
PostPosted: Thu Apr 12, 2007 3:13 pm 
Newbie

Joined: Thu Apr 12, 2007 2:54 pm
Posts: 1
Hibernate version: 3.2.1.GA

Mapping documents: Javax annotations

I have the following inheritance structure:

Class A
Class B extends A
Class C extends B

They are stored in the database using a Table-per-subclass strategy (InheritanceType.JOINED in javax.persistance). The ID is in class A and is a generated value.

I have an instance of class B (and therefore A) persisted to the database with a very specific ID. I am trying to "promote" the class B object to a class C object, keeping all of the values and the same ID.

Pseudo code:
B b = get from Hibernate
C c = new C();
copy all values from b into c including b's ID
persist(c);

When I follow that procedure I get a new row in all three table with a different ID that the one I set in object c and therefore different from the id of b. It is very important that I keep the same ID. I have looked though the documentation and forums and couldn't find a example of this and a solution. Any idea on how this could be done using hibernate would be much appreciated.

Thank you,

Centrion


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.