-->
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: Problem mapping nested objects
PostPosted: Thu Jun 07, 2007 12:20 pm 
Newbie

Joined: Thu Jun 07, 2007 8:07 am
Posts: 2
I've been struggling with this problem for about a week now. I've waded through the forum, faq, google search results, etc and found it most helpful for getting started. I'm now working on something more complex and need some further guidance. Below I've listed my Java classes (names changed for work reasons) with the relevant attributes and the corresponding sections of the hibernate mappings:

Class USER - List<CONTAINERA> list
Code:
<class name="USER" table="USER">
   <id name="ID" type="string" column="USER_ID"/>
<list name="list" table="USER_CONTAINERA" cascade="all,delete-orphan">
   <key column="USER_ID"/>
   <list-index column="NODE_ORDER"/>
   <one-to-many class="CONTAINERA"/>
</list>
</class>


Class CONTAINERA - List<TASK> tasks, List<CONTAINERB> cbs

Code:
<class name="CONTAINERA" table="CONTAINERA">
   <id name="ID" type="string" column="CONTAINERA_ID"/>
<list name="tasks" table="CONTAINERA_TASKS" cascade="all,delete-orphan" lazy="false">
   <key column="CONTAINERA_ID"/>
   <list-index column="NODE_ORDER"/>
   <one-to-many class="TASK"/>
</list>
      
<list name="cbs" table="CONTAINERA_CONTAINERB" cascade="all,delete-orphan" lazy="false">
   <key column="CONTAINERA_ID"/>
   <list-index column="NODE_ORDER"/>
   <one-to-many class="CONTAINERB"/>
</list>
</class>


Class TASK - List<TASK> subtasks

Code:
<class name="TASK" table="TASK">
   <id name="id" type="string" column="TASK_ID"/>
<list name="subtasks" table="TASK_SUBTASKS" cascade="all,delete-orphan" lazy="false">
   <key column="TASK_ID"/>
   <list-index column="NODE_ORDER"/>
   <one-to-many class="TASK" not-found="ignore"/>
</list>
</class>


Class CONTAINERB - ITEMA[] itemas, ITEMB[] itembs

Code:
<class name="CONTAINERB" table="CONTAINERB">
   <id name="ID" type="string" column="CONTAINERB_ID"/>
<array name="itemas" table="CONTAINERB_ITEMA" cascade="all,delete-orphan">
   <key column="CONTAINERB_ID"/>
   <list-index column="NODE_ORDER"/>
   <one-to-many class="ITEMA" not-found="ignore"/>
</array>
      
<array name="itembs" table="CONTAINERB_ITEMB" cascade="all,delete-orphan">
   <key column="CONTAINERB_ID"/>
   <list-index column="ENTITY_ORDER"/>
   <one-to-many class="ITEMB" not-found="ignore"/>
</array>
</class>


The problem is the tables for USER, CONTAINERA, CONTAINERB, ITEMA, and ITEMB are correct only when I specifically call session.saveOrUpdate() with the immediate container. For example, When I add a CONTAINERB object to CONTAINERA, I have to explicitly update CONTAINERA and not the USER who contains CONTAINERA as I would expect. Additionally the TASK table doesn't update even when I add a TASK to CONTAINERA and try to call update on the CONTAINERA.

Any input would be greatly appreciated.


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.