-->
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: two levels of subclassing gets wrong insert statement
PostPosted: Fri Jul 27, 2007 6:42 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
have a 3 layer hierarchy A, B, and C

<class name="A" >
<id name="enumItemId" type="int" column="ENUMITEMID">
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
<param name="max_lo">100</param>
</generator>
</id>
<property name="name" column="NAME" />

<union-subclass name="B" table="B">
<many-to-one name="user" class="User" column="USERID" not-null="true" insert="false" update="false" />
<property name="value" column="VALUE" type="serializable" />

<union-subclass name="C" table="C" />

</union-subclass>

as specified above, user is a required param.

when doing session.save(c), I checked and the attribute user is indeed present, but the insert statement says
insert into C (NAME, VALUE, ENUMITEMID) values (?, ?, ?)
without user.

and I get a
JDBCExceptionReporter:78 - Cannot add or update a child row: a foreign key constraint fails

why is that? did I declare the hbm wrong?


Top
 Profile  
 
 Post subject: Re: two levels of subclassing gets wrong insert statement
PostPosted: Fri Jul 27, 2007 7:00 pm 
Beginner
Beginner

Joined: Thu Apr 19, 2007 9:52 am
Posts: 27
You have insert=false, update=false
bhomass wrote:
<many-to-one name="user" class="User" column="USERID" not-null="true" insert="false" update="false" />

_________________
Regards,
Mahen
http://www.discoverabout.net
http://funnfacts.discoverabout.net


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 30, 2007 7:07 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
that's the right format for bi-directional one to one relationship according to
http://www.hibernate.org/hib_docs/v3/re ... tional-121

why do you point that out?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.