-->
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: Table per subclass
PostPosted: Tue Feb 19, 2008 12:22 am 
Newbie

Joined: Tue Feb 19, 2008 12:02 am
Posts: 2
Hi, I am having difficulties with inheritance in hibernate. I have two classes mapped on a table per subclass hierarchy. The two classes are BillingDetails and CreditCard with CreditCard inheriting from BillingDetails. The problem is the following: I have saved an object of type BillingDetails, then I copy its properties to a CreditCard object and when I try to save and update the CreditCard object Hibernate throws an org.hibernate.StaleObjectStateException

Can anyone give me an idea of how to have a BillingDetails at first, and then make it become a CreditCard object.

Thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 3:39 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
make a Constructor CreditCard(BillingDetails), which does not set the id.

load BillingDetails; construct CreditCard; delete BillingDetails; save CreditCard.

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: Table per subclass
PostPosted: Tue Feb 19, 2008 11:14 pm 
Newbie

Joined: Tue Feb 19, 2008 12:02 am
Posts: 2
Thanks for taking some time to help me out... I will try this solution and see how it works... Many thanks...


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.