-->
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: Join on the same table
PostPosted: Sat Jun 05, 2004 4:51 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 10:16 am
Posts: 33
Location: Cluj-Napoca, Romania
How do I implement in HSQL a query like this one:

Code:
select * from user user1 join user user2 on(user1.id = user2.id)


Many thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 1:54 am 
Newbie

Joined: Sat Oct 11, 2003 1:47 pm
Posts: 17
Im facing a similar issue of joining a table to itself as the original poster but using Criteria API. Do i need to have a mapping element to produce such a case of table joining to itself?

I couldnt find any reference in the forums. Any pointers greatly appreciated.

Thanks
Raja


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:40 am 
Newbie

Joined: Thu Jan 08, 2004 12:05 pm
Posts: 14
Try something like this:

Code:
from user user1 ,user user2 where user1.id = user2.id


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:44 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
You may also want to change it to be like this:

select user1, user2 from user user1 ,user user2 where user1.id = user2.id

And then when you get your list back, access each row via an object[], unless you have a defined object that contains two users' details.

The object[] would contain two objects, one at 0 and one at 1, you would then just typecast them as user.

-G


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.