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: Specifying two conditions on a join with Criteria API
PostPosted: Thu Sep 04, 2008 7:57 am 
Newbie

Joined: Tue Sep 02, 2008 7:02 am
Posts: 2
Hi, I am trying to write a query using the criteria API that joins to an associated collection and generally speaking it works OK. But I want to do a left outer join and qualify the join with two conditions rather than have the one condition qualifying the join and one condition in the where clause.

e.g.

_session.CreateCriteria(typeof(IPlan))
.CreateCriteria("LinkedImpacts", "LI", JoinType.LeftOuterJoin)
.Add(Expression.IdEq(25))
.AddOrder(Order.Asc("LI.Id"))
.List<IPlan>();

generates something like:

select p.planid, p.name, i.impactid as linked
from rm_plan p left outer join rm_impact i
on i.planid = p.planid
where i.impactid = 25
order by linked

whereas I want:

select p.planid, p.name, i.impactid as linked
from rm_plan p left outer join rm_impact i
on i.planid = p.planid
and i.impactid = 25
order by linked

The latter is subtly different and gives me different results (which is what I want). Is there a way to achieve this using the criteria API?

Thanks in advance.

Julian Jelfs


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.