-->
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.  [ 5 posts ] 
Author Message
 Post subject: join table without association
PostPosted: Thu Jul 03, 2008 9:54 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
is there any way to create criteria for joining 2 table without association?
ex for SQL created : select student.* from student, member where student.name = member.name


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 1:41 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You could just add a restriction:

Restrictions.sqlRestriction("***.name in (select name from member)")

Something like that.

Here's a little tutorial on using the Hibernate Critieria API from my website. You might find it helpful:

How to Use the Criteria API in you Hibernate Applications: A Simple Tutorial

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Last edited by Cameron McKenzie on Fri Jul 25, 2008 4:25 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 9:54 pm 
Newbie

Joined: Thu Jul 24, 2008 12:44 pm
Posts: 1
Code:
Criteria criteria = session.createCriteria(Student.class);
criteria.add(Restrictions.sqlRestriction("{alias}.name in (select name from member)");



-- suresh --


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 2:04 am 
Newbie

Joined: Fri Jul 25, 2008 1:55 am
Posts: 1
Great!
Thanks for the info.. :)

_________________
MrLongDistance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 18, 2008 8:29 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Thanks for the info :)


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