-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate 2: Write hql query to join 3 unrelated classes
PostPosted: Sun Jul 26, 2009 6:42 pm 
Newbie

Joined: Sun Jul 26, 2009 6:39 pm
Posts: 2
Hi,
I am a newbie and having trouble writing a query to join 3 unrelated classes ClassA, ClassB, ClassC.
Here are the details (and I will show in code below).. ClassA has long attribute that will match the id of ClassB (but the id of ClassB is Long). ClassB has attribute of type ClassC. ClassC has attribute of type string.
Here is the code:
Code:
public class ClassA {
....
long classBid;
....
}

public class ClassB {
....
Long id;
ClassC classC;
....


public class ClassC {
String name;



here are the hbm relevant lines:
ClassA hbm:
Code:
<property name="classBid" not-null="true" column="CBID">


ClassB hbm:
Code:
<many-to-one not-null="false" column="CLASS_C" name="classC">


ClassC hbm:
Code:
<property name="name" not-null="true" column="NAME">


I want to get all objects of ClassA where ClassA.classBid=ClassB.id and ClassB.classC=ClassC and ClassC.name="abc"

Thanks,
John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.