-->
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: First opbject in List is null
PostPosted: Mon Apr 18, 2005 5:55 am 
Newbie

Joined: Mon Apr 18, 2005 4:40 am
Posts: 2
I'm fearly new to the use of hibernate.. but I have made some stuff that worked.. but now I have run into at problem that I can't solve.

I have mappings that look like this:

<hibernate-mapping package="db">
<class name="Number" table="numbers" >
<id name="id" column="number_id" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<property name="number" column="number" type="string" length="25" />
<property name="type" column="type" type="string" length="25"/>
<property name="status" column="status" type="string" length="25"/>
<many-to-one name="series" class="NumberSeries" column="series_id" not-null="true" />
</class>
</hibernate-mapping>

<hibernate-mapping package="db">
<class name="NumberSeries" table="numberseries" >
<id name="id" column="series_id" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<property name="start" column="start" type="string" length="25" />
<property name="end" column="end" type="string" length="25"/>
<property name="status" column="status" type="string" length="25"/>
<list name="numbers" cascade="all" inverse="true" lazy="true">
<key column="series_id" />
<index column="number_id" />
<one-to-many class="Number" />
</list>
</class>
</hibernate-mapping>


But when I retrieve the list with getNumbers() it contains the correcet objects but the first object in the list is 'null'.

Anybody have any idea what I'm doing wrong?

_________________
// Thorsager


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 9:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
List uses an Index. The index determines the position in the list. If the index positions have gaps then a null will be in that position of the list. Check your index values don't have gaps and start with the first index 0.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 19, 2005 5:00 am 
Newbie

Joined: Mon Apr 18, 2005 4:40 am
Posts: 2
Thanx.. It all makes sense now :)

_________________
// Thorsager


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.