-->
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: Null entities if list-index not sequential?
PostPosted: Wed Jun 14, 2006 11:18 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
Hibernate version: 3.1
Name and version of the database you are using: SQL Server

The following use of <list> and <list-index> results in a java.util.List of 8 elements with a null for the 4th and 6th element. I was expecting a List of 6 elements where the missing 4 and 6 is ignored.

Is this correct behaviour?

Many thanks,

PS: I do rate :-)

Mapping documents:
Code:
<class name="eg.Stage" table="stage">
<list name="elements" inverse="true" cascade="all">
  <key column="stage_id"/>
  <list-index column="sequence" base="1"/>
  <one-to-many class="eg.Element"/>
</list>
</class>

Code:
select * from element where stage_id = ?;
gives:
Code:
id          stage_id    sequence   
----------- ----------- -----------
573         708         1         
574         708         2       
575         708         3       <-- Note 4 is missing
576         708         5       <-- Note 6 is missing
577         708         7     
578         708         8         

Code:
stage.getElements().toString();
gives:
Code:
[1, 2, 3, null, 5, null, 7, 8]

_________________
Stewart
London, UK


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 14, 2006 7:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Yes this is correct (as in expected) behaviour.

Think in terms of the index being exactly that an index into an array structure.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 6:38 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
Thank you very much indeed.

_________________
Stewart
London, UK


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.