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: Criteria query
PostPosted: Mon Jun 02, 2008 10:29 am 
Newbie

Joined: Tue Oct 23, 2007 6:41 am
Posts: 6
Hi forum,

I have those objects:

Parent (some properties).
Child (properties: Parent (reference to Parent, many-to-one), Value.

How can I specify criteria query for:
"select p from Parent p, Child c where c.Parent = p and c.Value = 'something'?

I would like to do it through criteria query but I don't have any clue how to define it, because I have only relation from child to parent.

Thanks for your help

Smoke


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 04, 2008 3:22 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Try something like

Code:
ICriteria crit = session.CreateCriteria(typeof(Child))
   .Add(Expression.Eq("Parent", p)
   .Add(Expression.Eq("Value", v)
   .SetProjection(Projection.Property("Parent"));

_________________
--Wolfgang


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.