-->
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: collection with subclasses - insert them to their tables
PostPosted: Mon Aug 13, 2007 2:38 pm 
Newbie

Joined: Sat Jul 28, 2007 7:24 am
Posts: 8
Hello all.
I have a problem with a collection with implicit polimorphizm. I have classes: Container (table CONTAINER), Parent (PARENT) and Child(CHILD). Child extends Parent. Container has a set of Parent objects, mapped like this:

<set name="parents" table="PARENT" cascade="save-update, delete, delete-orphan" inverse="true">
<key column="CONTAINER_ID" />
<one-to-many class="Base" />
</set>

The set in Container is HashSet<Parent>.
Both Parent and Child are mapped separately to their corresponding tables, and have the Container property:

<many-to-one name="container" class="Container" column="CONTAINER_ID" foreign-key="PARENT_TO_CONTAINER_ID" />

Now, in the code I create both Parent and child objects and add them to the collection. When I save the container, all the objects are inserted into the PARENT table, the CHILD is empty.
How can I change the mappings so that Child objects would be saved in the CHILD table? Is it possible with implicit polymorphizm, or do I have to use some other strategy to store hierarchies?


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.