-->
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: How to write subquery using criterian api in hibernate.
PostPosted: Fri Jan 08, 2010 12:53 am 
Newbie

Joined: Mon Jan 04, 2010 4:31 am
Posts: 2
I have the HQL query like.Please let me know how to write criterian query for this.
String queryString = "from Customer as customer where customer.username like '%"+customer+"%' and " +
" customer.statusMap="+StatusMapInterface.ACTIVE+" and " +
" customer.customerId in (select distinct cRole.customer from CustomerRole as cRole where cRole.role!="+RoleMap.SITEADMIN+")" +
" order by registeredDate asc ";

In the above query Customer is the parent table. Customer_Role is the child table.In that customer_id the foreign key to Customer table.

Please let me know how to write subquery in "in clause" using criterian api of hibernate. My subquery is like

select distinct cRole.customer from CustomerRole as cRole where cRole.role!="+RoleMap.SITEADMIN.
In above subquery i want only one column customer_id which is the foreign key.

I had spent almost 10 hours for this. Even i cant get this.
Please any one give reply

Thanks in Advance..


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.