-->
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.  [ 7 posts ] 
Author Message
 Post subject: First element of List is null, why ?
PostPosted: Thu Mar 18, 2004 8:47 am 
Newbie

Joined: Mon Feb 16, 2004 7:11 am
Posts: 13
Hey everybody!

Hopefully I am not asking stupid thing again, but here I go :)!
I have an Object called "Akquise" which has several statistic-entries.
Since that Statistic-Table is somewhat big, I would like to use lazy-init on the respective collection:

Code:
<list name="statistics" lazy="true">
   <key column="BATCHLFDNR" />
   <index column="ZEILE" />
   <one-to-many class="az.dias.miner.application.dao.AkquiseStatistik"/>
</list>


All works so far. My code to retrieve the statistik at the point where I need it looks this way:

Code:
Akquise a = (Akquise) session.get(Akquise.class,new Integer(id));

for(Iterator i = a.getStatistics().iterator(); i.hasNext();)
{
   AkquiseStatistik as = (AkquiseStatistik) i.next();
   System.out.println(as);
}


Now I have the following problem. The first element in the returnend iterator is always null. I could work around that, but I'd rather like to know if this is normal, or if I do something wrong.

Thx for the help!

Console-Log:

Code:
13:37:03,207 INFO  [STDOUT] null
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16
13:37:03,207 INFO  [STDOUT] az.dias.miner.application.dao.AkquiseStatistik@44333b16


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 9:02 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
If your index column starts with 1, then yes, it is normal for hibernate to place a null as first item in your list.

James


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 9:08 am 
Newbie

Joined: Mon Feb 16, 2004 7:11 am
Posts: 13
OK, now the question would be why??
Is it simply iterating over the numbers from 0-n?
I always thought it would do an "ORDER BY" on the <index> column...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, the index column is exactly the index position of the element in the list.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you know about order-by, right?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 4:49 am 
Newbie

Joined: Mon Feb 16, 2004 7:11 am
Posts: 13
The "always exact-index"-info was all that I need for explanation.
And yes, I know what ORDER BY is about.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 5:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummm. I'm quite sure you know what ORDER BY means in SQL. But do you know what the order-by attribute of a collection mapping does?


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