-->
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.  [ 2 posts ] 
Author Message
 Post subject: One to one null or field value
PostPosted: Fri Apr 10, 2009 11:20 am 
Newbie

Joined: Fri Apr 10, 2009 10:47 am
Posts: 1
Hi all,

I am HB-Newbe.
Problem seems easy, only 2 tables to make a select: table person and table persondetails, 1:1, both with same ids as pk, in hybernate i made annotation one to one. Initially most persons have not a associated persondetail in the db.

I want get a list of all persons who have a specific field in persondetails set to false OR who have not (yet) a persondetails entry in the db.

Many thanks!

(ps: i managed to get the persons with persondetails-field false with a alias rsp additional "criteria.createCriteria(persondetails...," but i cant figure out how to combine that with a "OR persondetail is null":-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 13, 2009 8:49 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
Try something like:

select p from Person p where p.personDetails is null or p.personDetails.someField = false

I haven't tested this :) Generally I find HQL a lot simpler than Criteria...

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


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