-->
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.  [ 2 posts ] 
Author Message
 Post subject: One-to-many self association using List
PostPosted: Thu Nov 02, 2006 11:17 pm 
Newbie

Joined: Sat Jul 08, 2006 8:44 am
Posts: 6
I have a one-to-many self association that was working fine as TreeSet with sort=natural. I decided to switch to using List but Hibernate keeps complaining about "null index column for collection." Here is my mapping (Note the set is commented out but was working fine for me.)

<class name="CategoryImpl" table="CATEGORY">
<id name="id">
<generator class="native"/>
</id>
<property name="name" type="text"/>
<list name="childCategories"
table="CATEGORY"
inverse="true"
cascade="all">
<key column="PARENT_CATEGORY_ID"/>
<index column="SEQUENCE_COL"/>
<one-to-many class="CategoryImpl"/>
</list>
<!--
<set name="childCategories"
table="category"
sort="natural"
inverse="true"
cascade="all">
<key column="PARENT_CATEGORY_ID"/>
<one-to-many class="CategoryImpl"/>
</set>
-->
<many-to-one
name="parentCategory"
column="PARENT_CATEGORY_ID"
class="CategoryImpl"/>
</class>

Any help would be greatly appreciated. I've tried looking everywhere but I can't seem to find anything specific to a *self* association.

TIA.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:29 pm 
Newbie

Joined: Sat Jul 08, 2006 8:44 am
Posts: 6
I was able to stop the error by adding a sequence to my CategoryImpl class and mapping it as follows:

<property name="sequence" column="SEQUENCE_COL"/>

I had actually tried this earlier but my IDE was not picking up the new mapping file during testing (GRRR.)

Anyways, there is still a problem b/c the child categories are not being stored in the order that they are added to the list. Is this because of the inverse=true on the many end?


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