-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-many and inheritence mapping
PostPosted: Sun Apr 23, 2006 2:09 pm 
Newbie

Joined: Fri May 21, 2004 3:25 pm
Posts: 8
Location: Los Angeles
Hi All,
When a class has one-to-many relation with 2 sibling classes, and has cascade set to all, the siblings are being persisted with the primary key of the parent class and not their own.

detailed explanation:
I have a class Owner which has onetomany relations with 2 sibling classes (CalendarEvent and PlannerEvent, which extend TimedEvent).
When I try and persist the Owner, it always fails at the second onetomany mapping because it is trying to insert the primary key of the table timedevent into the child foreign key.

All the Ids are being generated using
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
using the auto-increment feature of mysql.
If you look at the sql:
There are 2 inserts into the timedevent table one for the calendar event and one for the planner event.

But the inserts into the link tables are using timedevent primary key instead of the subclass primary key.

Any help is appreciated.

Thanks,
Vamsi Putrevu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 12:44 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Your mapping is wrong. Re-read the relevant sections of the ref docs. The most likely source of the error is the inverse many-to-one mapping: see section 21.2 of the 3.1 ref docs. If you can't figure it out, post your mapping: if possible, convert it to .hbm.xml format first, as annotations are much harder to read at a glance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 1:31 pm 
Newbie

Joined: Wed Apr 19, 2006 2:51 pm
Posts: 16
Hi tenwit !

I have just posted a new topic that deals with a very similar issue to the one posted by vamsi06 !

http://forum.hibernate.org/viewtopic.php?t=958602

Do you think you could give a hint to help us look to the correct direction ?

Thanks a lot for support !

_________________
Cheers,
Laurent

Thanks for rating in case it helped !


Top
 Profile  
 
 Post subject: detailed post
PostPosted: Fri Apr 28, 2006 7:11 pm 
Newbie

Joined: Fri May 21, 2004 3:25 pm
Posts: 8
Location: Los Angeles
Hi,
I had previously posted the detailed message. This error still persists.
Thanks,
Vamsi

http://forum.hibernate.org/viewtopic.ph ... highlight=


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.