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: hsql on null-reference / order-by
PostPosted: Sun Jun 10, 2007 5:56 am 
Newbie

Joined: Tue Oct 24, 2006 6:24 am
Posts: 7
Hibernate version:
java 6.0:
mysql 6.0:

hi,

query:
Code:
hsqlQuery = "FROM client WHERE company=null ";

returns a correct result

query:
Code:
hsqlQuery = "FROM client WHERE company.name='eine Firma' ";

returns also a correct result

BUT:
Code:
hsqlQuery = "FROM client WHERE company=null OR company.name='Firma1'";

returns only companies where company NOT IS NULL.


the same problem occurs, when i try to order the clients by company.name. null companies are missing in the result.

so why does hibernate loose rows in the result, where references are NULL??

any clues/hints ?

thx in advance
franky


Code:
<class name="client" table="client">
   <id name="id" column="ID" type="long">
      <generator class="native"/>
   </id>
   <property name="firstname" column="firstname" />
   <many-to-one name="company" column="ID_company" class="company" lazy="false" fetch="join"/>
</class>
   
<class name="company" table="company">
   <id name="id" column="ID" type="long">
      <generator class="native"/>
   </id>
   <property name="name" column="name"/>
</class>
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 10, 2007 9:18 am 
Newbie

Joined: Sun Apr 09, 2006 7:27 am
Posts: 3
Location: Zürich, Switzerland
Hi,

How about something like:

Code:
FROM client left join fetch company.name companyName WHERE companyName=null OR company.name='Firma1'


I just encountered a similiar problem, and found a solution here:
http://forum.hibernate.org/viewtopic.php?p=2294855


Top
 Profile  
 
 Post subject: thx
PostPosted: Sun Jun 10, 2007 7:23 pm 
Newbie

Joined: Tue Oct 24, 2006 6:24 am
Posts: 7
yepp, this works!

thx & greets
franky


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.