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: is this a bug of hibernate?
PostPosted: Thu Nov 11, 2010 9:28 pm 
Newbie

Joined: Thu Nov 11, 2010 9:23 pm
Posts: 2
user is one to one with address,i want to find users who's address is null ,i use the codes as follows:
Session session = sessionFactory.openSession();

Criteria query = session.createCriteria(User.class);



query.add(Restrictions.isNotNull("address"));

query.setMaxResults(limit);
List<User> users = query.list();


it does't work
i check the sql that hibernate generates

...from user this_ left outer join address address2_ on this_.Id=address2_.userId
where this_.Id is not null limit ?

it's wrong
this_.id should be address2_Id,i dont know whether it's a bug


Top
 Profile  
 
 Post subject: Re: is this a bug of hibernate?
PostPosted: Fri Nov 12, 2010 4:56 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
It is not a bug.


Top
 Profile  
 
 Post subject: Re: is this a bug of hibernate?
PostPosted: Fri Nov 12, 2010 5:07 am 
Newbie

Joined: Thu Nov 11, 2010 9:23 pm
Posts: 2
o,so how to find users who's address is null?


Top
 Profile  
 
 Post subject: Re: is this a bug of hibernate?
PostPosted: Fri Nov 12, 2010 10:37 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
First of all you need to use "isNull" instead of "isNotNull".

Nevertheless, I hate criteria, so I would use HQL instead.


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.