-->
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: Strange Query result
PostPosted: Thu Aug 17, 2006 9:12 am 
Newbie

Joined: Thu Aug 17, 2006 8:59 am
Posts: 7
Hi, when I have following classes and mappings:

Code:
class Party {
             int id;
             List taxPayers;
             
             ... getters and setters.
}

class TaxPayer {
int id;
Party party;

... getters and setters.
}



Party.hbm.xml:

Code:
......
<list name="taxPayers" inverse="true" cascade="save-update">
  <key-column="party_id" not-null="true"/>
  <list-index column="id"/>
  <one-to-many class="TaxPayer"/>
</list>


TaxPayer.hbm.xml:
Code:
....
<many-to-one name="party" column="party_id" class="Party" not-null="true"/>


Following Query gives me some strange result:

Code:
Query query = session.createQuery("select p from Party p inner join p.taxPayers where something like ?").setString(0, "some value");

List result = query.list();


Result list is populated with first 3 null objects then with good object. Why?

Thanks a lot.
Andrija.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 9:21 am 
Newbie

Joined: Thu Aug 17, 2006 8:59 am
Posts: 7
Sorry, my mistake in previous post. What I want to say every Party from result of the query has a list of TaxPayers which has 3 null objects and then right one. I executed same query with Criteria and with NamedQuery but results are the same.

Thnx.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 10:45 am 
Newbie

Joined: Thu Aug 17, 2006 8:59 am
Posts: 7
OK I found what is cause of problem:
it's in mapping
Code:
<list-index column="id"/>

whene id is 3 in list I will get three null object then a real one.
How to solve this? What should I put in column name? I need indexed collection so Set is out of question.

Thnx.


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.