-->
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: Dynamic query using criteria joining two tables
PostPosted: Tue Aug 10, 2010 1:49 am 
Newbie

Joined: Tue Aug 10, 2010 1:38 am
Posts: 1
Hi All,

I need to build a search query using three tables. Tables are linked like this,

I need TABLE_A objects from database.

TABLE_B contains TABLE_A as FK.

TABLE_C contains TABLE_B as FK.

depending on some parameters, I need to build a query that checks TABLE_C, TABLE_B and TABLE_A and returns me TABLE_A objects.

I am using criteria api for querying TABLE_A, can I build query by using criteria api and join TABLE_B and TABLE_C so that I can fetch TABLE_A objects.

Is this possible by using criteria api. If not please suggest me the best approach.

Thanks,
Vamsi


Top
 Profile  
 
 Post subject: Re: Dynamic query using criteria joining two tables
PostPosted: Tue Aug 10, 2010 4:49 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi gvamsikris,

If you well known with SQL, then it can be converted to HQL easily. Since this is a validation done at child entity, it is best filter using where condition after applying joins properly.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


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.