-->
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: How to write left join query with a where clause
PostPosted: Mon Jul 19, 2004 5:48 am 
Newbie

Joined: Fri Jul 16, 2004 9:38 am
Posts: 1
hi ,
I have a typical query which needs to be executed thru hibernate.
Can anyone suggest ,how to map to hibernate configuration.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 7:59 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Code:
public class Foo
{
..
    private Foo1 foo1;
    // maybe List listOfFoo1;
..
}

public class Foo1
{
...
    private Foo2 foo2;
    // maybe List listOfFoo2;
...
}

public class Foo2
{
...
    private Foo2 foo3;
    //maybe List listOfFoo3;
...
}


then in HQL you could write:
Code:
select foo from Foo foo
    inner join foo.foo1 foo1
    inner join foo1.foo2 foo2
    inner join foo2.foo3 foo3
where foo3.service = "Y"

or even simpler:
Code:
select foo from Foo foo
where foo.foo1.foo2.foo3.service = "Y"

in the case when in Foo you have listOfFoo1
you should use:
Code:
inner join foo.listOfFoo1 listOfFoo1Element


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 8:02 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Forget about List listOfFoo1, List listOfFoo2, etc :)
I see you used shared ID for all Foo, Foo1, Foo2, Foo3, then you could not use collection for associations.


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.