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: mapping trouble with <list> association
PostPosted: Wed Oct 10, 2007 3:04 am 
Newbie

Joined: Wed Oct 10, 2007 2:25 am
Posts: 2
Hello dear colleagues!

I have trouble with <list> association.

I will try to explain.
I have UserGroup 1:n QuestionGroup relation.
Here is the mapping code..

UserGroup:
Code:
<class name="model.UserGroup" table="USER_GROUP">
   <id name="id" type="long" column="ID">
      <generator class="increment"/>
   </id>
   <many-to-one name="assess" column="ASSESS_ID" class="model.Assess" not-null="true"/>
   <property name="name" column="NAME" type="string" length="250"/>
   <property name="description" column="DESCRIPTION" type="string" length="4000"/>
   <property name="created" column="CREATED" type="date"/>
   <property name="updated" column="UPDATED" type="date"/>
   <set name="users">
      <key column="USER_GROUP_ID"/>
      <one-to-many class="model.User"/>
   </set>
   <list name="questionGroups">
      <key column="USER_GROUP_ID"/>
      <list-index column="SORTER"/>
      <one-to-many class="model.QuestionGroup"/>
   </list>
</class>


QuestionGroup:
Code:
<class name="model.QuestionGroup" table="QUESTION_GROUP">
   <id name="id" type="long" column="ID">
      <generator class="increment"></generator>
   </id>
   <many-to-one name="userGroup" column="USER_GROUP_ID" class="model.UserGroup" not-null="true"/>
   <property name="name" type="string" length="250"></property>
   <property name="description" type="string" length="4000"></property>
   <property name="sorter" type="integer"></property>
   <property name="created" type="date"></property>
   <property name="updated" type="date"></property>
   <list name="questions">
      <key column="QUESTION_GROUP_ID"/>
      <list-index column="SORTER"></list-index>
      <one-to-many class="model.Question"/>
   </list>
</class>


When I get one UserGroup by primary key and after that try to access to List questions - lazy init loads the questionGroups, but instead of real quantity (4 rows) it returns List with 404 rows.

When I run debug and look to List questions I see the following:
[null,null,null.....(x99),model.Object, null, null (x99), model.Object... etc]

It loads my 4 rows, but with many null values.
What can be wrong?


p.s. I use <list> instead of <set> because I need it to use in JSF datatable tag.... If you could suggest another way, I would be glad to learn.

thank you in advance!


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.