-->
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: help needed in HQL query
PostPosted: Wed Sep 08, 2004 9:26 pm 
Newbie

Joined: Thu Oct 16, 2003 7:55 pm
Posts: 4
[b]Hibernate version:[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]Debug level Hibernate log excerpt:[/b]

Hi,

I have three tables A, B and i want to write query like this

select a,b from A as a, B as b
where a.x=1 and
a.y = b.y (+) --> y may be not available in table b
and b.z.id =0 ( z may be be null or reference to another object/table).

I want the query to return the records if b.z is null or b.z.id = 0

How can i write this query in HQL?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 7:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
something like
Code:
select a,b from A as a left join a.b as b
where a.x=1
and (b.z.id =0 b.z.id=null)


this work if a is associated to b via many-to-one and will return object[]


but this can be wrong, it would be better to show us mapping files

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.