-->
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.  [ 4 posts ] 
Author Message
 Post subject: Null Items appear in the list when data reteived
PostPosted: Fri May 25, 2007 5:56 am 
Newbie

Joined: Wed Jul 06, 2005 12:39 pm
Posts: 8
Location: UK
Hi I have a problem with nulls appearing a the begining of my list of SelectedFees when they are retrieved from the database.

There are no extra rows in the database. The only thing i can think of is null objects are being cached somewhere an not being removed??

Any help would be much appreciated.

cheers



The mapping for this list is below.

Hibernate version: 3.1

Mapping documents:

<list name="fees" lazy="false" cascade="all-delete-orphan" optimistic-lock="false">
<key>
<column name="ENQAPPID" />
</key>
<list-index column="IDENTIFIER" base="1" />
<one-to-many
class="fee.SelectedFee"/>
</list>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 6:24 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

what cacheing you are using. and send mapping file and code


Amila


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 8:48 am 
Newbie

Joined: Wed Jul 06, 2005 12:39 pm
Posts: 8
Location: UK
Hi amila733

Thank for you response. I think I have found the problem. It seems that if I have one row with id 7 in my database table then 6 nulls are added before the actual selected object in the list.

No idea why this is happening. Very strange if you ask me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 9:04 am 
Newbie

Joined: Fri May 25, 2007 6:06 am
Posts: 3
I've had this problem before. it's happening because you're using a list collection type. A list is an ordered collection that defines it's ordering based on the list-index-column you provide. If you have one row with an index of 7, hibernate will say 'OK, this is an ordered list, and this element is in position 7'. Therefore it will create a list object with a length of 7 were the first 6 entries are null (as there is not data for those indicies). This is all so that the semantics of the 'list' type are preserved.

If the ordering is significant within your application, then you need to make sure that you are maintaining the index column correctly. If is not, then you can avoid this problem by using one of the unordered collection types, such as a set.

Jason.


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