-->
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: Criteria question
PostPosted: Tue Oct 09, 2007 9:13 am 
Newbie

Joined: Thu Sep 13, 2007 4:00 pm
Posts: 11
Hi all,
I'm just starting with Hibernate.
I have a Product class that has a collection of UserPermission type.
I want to get a list of all products that HAVE a UserPermission which UserCode equals 12345.

How do I do that?

Thanks in advance

_________________
André Rodrigues Pena


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 10:02 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
select p from Product P where p.UserPermission.UserCode=12345

Hope that helps else you can go through this link in order to have more info on querying.

http://www.hibernate.org/hib_docs/v3/re ... /#queryhql


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 1:33 pm 
Newbie

Joined: Thu Sep 13, 2007 4:00 pm
Posts: 11
thanks Seth. I forgot to say that I was expecting the result via Criteria. Can you help me?

_________________
André Rodrigues Pena


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 10, 2007 12:14 am 
Newbie

Joined: Thu Oct 04, 2007 5:00 am
Posts: 13
Criteria API lacks way of subselecting within a collection
please follow the link:-
http://opensource.atlassian.com/project ... e/HHH-1509

Sandip Gaikwad.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 10, 2007 2:17 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
Try this for criteria api

List product = session.createCriteria(Product.class)
.createAlias("UserPermission", "up")
.add( Restrictions.eq("up.UserCode", 12345) )
.list();

Go through this link for more info on criteria queries

http://www.hibernate.org/hib_docs/v3/re ... rycriteria


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.