-->
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: From HQL to CreateCriteria
PostPosted: Tue Dec 30, 2008 11:02 am 
Newbie

Joined: Thu Jul 03, 2008 11:16 am
Posts: 7
Someone who knows how to translate this HQL-statement to CreateCritera:

The tricky part is to join obs.Art with obs1.Art in the MIN-clause.

from Obs obs where obs.Datum = (select MIN(obs1.Datum) from Obs obs1 where obs.Art = obs1.Art)
ORDER BY obs.Art, obs.Datum, obs.Lopnr

Thanks in advance!

// SuperMattet


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 11:15 am 
Expert
Expert

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

Code:
DetachedCriteria sub = DetachedCriteria.For(typeof(Obs), "obs1")
   .Add(Expression.EqProperty("obs.Art", "obs1.Art"))
   .SetProjection(Projections.Min("obs1.Datum"));

ICriteria crit = session.CreateCritera(typeof(Obs),"obs"))
.Add(Subqueries.PropertyEq("obs.Datum", sub))
.AddOrder(....);

_________________
--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.