-->
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.  [ 3 posts ] 
Author Message
 Post subject: List returned contains null elements
PostPosted: Wed Sep 10, 2003 2:05 pm 
Newbie

Joined: Mon Sep 08, 2003 12:32 pm
Posts: 10
Hi,
I don't understand how come the list of division contains null values !

Session session = getSessionFactory().openSession();
Grille grille = (Grille) session.load(Grille.class, new Long(id));
for (Iterator divIdx = divisionList.iterator(); divIdx.hasNext();) {
Divisions div = (Divisions) divIdx.next();
div.getId(); <<<<<<<<<<<<<<<< bombs here because div is null !!
}

What did I do wrong here ?
--------------

I have this mapping:

<hibernate-mapping default-cascade="none">
<class name="com.accovia.domain.Grille" table="grille" polymorphism="implicit" mutable="true">

<id column="grille_id" name="id" type="long" unsaved-value="any">
<generator class="native" />
</id>

<property column="description_grille" length="30" name="descriptionGrille" type="string" unique="false" not-null="true" />
<property column="libelle_prix" length="30" name="libellePrix" type="string" unique="false" not-null="false" />

<list name="divisionList" table="divisions" inverse="false" lazy="false">
<key column="grille_id"/>
<index column="division"/>
<one-to-many class="com.accovia.domain.Divisions"/>
</list>
</class>
</hibernate-mapping>

------------------------
thanks in advance.
thanh.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This looks wrong:

<index column="division"/>

Are you sure you shouldn't be using a <bag> mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:41 pm 
Newbie

Joined: Mon Sep 08, 2003 12:32 pm
Posts: 10
Thanks Gavin for the prompt reply.
It works!

For the people who might read this:

<list> mapping is changed to <bag> as follows:

<bag name="divisionList" table="divisions" inverse="false" lazy="false">
<key column="grille_id"/>
<one-to-many class="com.accovia.domain.Divisions"/>
</bag>


/tn/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.