-->
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: List within a list?
PostPosted: Sat Jun 11, 2011 12:23 am 
Newbie

Joined: Sat May 07, 2011 6:47 pm
Posts: 3
I have been working several hours on creating a list within a list in hibernate. I have a parent object with a list of children, and each child can have a list associated with it.

Parent table
parentid, (several fields)
From the mapping:
<list name="children" table="child_1" cascade="all">
<key column="parentId"/>
<index column="listIndex"/>
<one-to-many class="test.Child1"/>
</list>

Child 1 table:
id (auto-incremented), parentId (links to parent table), name, description, listIndex
From the mapping:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="test.Child1" table="child_1">
<id name="id" column="id" type="long">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="description"/>
<list name="values" table="child_value">
<key column="id"/>
<index column="listIndex"/>
<many-to-many column="value" class="test.Value"/>
</list>
</class>

</hibernate-mapping>
<!-- parsed in 0ms -->

Child 2 table:
id (links to child table's id), value (links to another table), listIndex
(linked from other mapping)

Everything worked fine until I added the id column and third table. I had it more or less working, but was getting hibernate errors every other transaction (problems with all-delete-orphan, which was not solved by clearing the list, and manually deleting the items didn't work either). I would like to implement a double layered list, but I would like to eliminate the "id" column from the first child table. Is there a clean way to do this? Like, for instance, is there any way I could implement the third child to have the link to id and listIndex of the first child table, coupled with a listIndex2 as a composite key of 3?


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