-->
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: error on joined-subclass insertion, when parent exists
PostPosted: Thu Oct 23, 2008 8:12 am 
Newbie

Joined: Wed Oct 22, 2008 11:23 pm
Posts: 2
the mapping is like this:

[code]<class name="FirstObject" table="FirstObjects">
<id name="firstObjectId" type="long">
<generator class="native"/>
</id>
<property name="propertyOfFirstObject"/>
<joined-subclass name="SecondObject" table="SecondObjects">
<key column="firstObjectId"/>
<property name="propertyOfSecondObject"/>
<joined-subclass name="ThirdObject" table="ThirdObjects">
<key column="secondObjectId"/>
<property name="propertyOfThirdObject"/>
</joined-subclass>
</joined-subclass>
</class> [/code]

The SecondObject already exists in database. Now I want to insert one ThirdObject.

if I do:
SecondObject s = session.load(SecondObject.class, firstObjectId);
ThirdObject t = new ThirdObject ();
t.setId(s.getId());
t.setPropertyOfThirdObject("test");
session.save(t);

I got this error:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:

if i do session.merge(t), i got this error:
org.hibernate.WrongClassException: Object with id: null was not of the specified subclass:


Any idea?

Thanks!


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.