-->
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: Table per subclass and NonUniqueObjectException
PostPosted: Fri Jul 20, 2007 8:50 am 
Newbie

Joined: Fri Jul 20, 2007 7:01 am
Posts: 1
Location: Australia
Firstly, let me apologize if this is a stupid question, I have been through the FAQ's, I bought the recommended book Java Persistence with Hibernate.

It is such a simple question I feel so stupid, but it is annoying me so I though I would ask, an hope you don't all beat me up :)

So using the example in the book, with Billing_Details(superclass), Credit_card(subclass) and Bank_account(subclass).

I create an instance of credit_card, and an instance of bank_account

I persist credit_card
I then persist bank_account and get org.hibernate.NonUniqueObjectException
(in the same session)

Now maybe I missed something, and my understanding of hibernate is wrong.

What I thought would happen is it would save credit_card, thus creating the row in credit_card and billing_details.

Then when it went to persist bank_account, it would detect that the billing details already exist(because I just saved it with credit card), and just create the row in bank_account, thus linking it to the billing details.

I have tried this example using native hibernate, and the entity manager, and get the same issue. (hence why I think it is me)

With the entity manager I used em.persist and em.merge and got the same problem. (I tried .save and .saveorupdate in native)

(I am using postgress as the backend db, and all the latest release versions of hibernate stuff.)

So I am sorry, that it is just probably my understanding.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 20, 2007 10:21 am 
Newbie

Joined: Thu Jul 12, 2007 12:52 pm
Posts: 5
Location: Boise, Idaho USA
I'm new with hibernate myself...I'm not totally sure, but you may need to call flush() after saving credit_card and before saving bank_account.


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.