-->
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: DetachedCriteria Projections and Outer joins
PostPosted: Thu Mar 01, 2007 12:10 pm 
Newbie

Joined: Thu May 04, 2006 3:58 am
Posts: 4
Hi,

I'm using Hibernate version:3.1 and I'm having real problems using detached criteria to produce sql with an outer join. I'm trying to get Hibernate to produce sql along these lines...

Code:
select
company.name,
outcome.name
from
WorkItems this
inner join Companies company on this.com_id=company.com_id
left outer join Outcomes outcome on this.o_id=outcome.o_id
where company.com_id = 'xxx'


I have included below a fragment of code that should show one of the ways that I have tried to get this to work, however I always end up with an inner join being generated. Please help, what am I doing wrong?

Code:
DetachedCriteria criteria = DetachedCriteria.forClass(WorkItem.class);
criteria = criteria.createAlias("company","company");
criteria = criteria.add(Expression.eq("company.id", "xxx"));

criteria = criteria.createAlias("outcome", "outcome").setFetchMode("outcome", FetchMode.JOIN);

ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.property("company.name"));
projectionList.add(Projections.property("outcome.name"));

criteria = criteria.setProjection(projectionList);

Criteria realCriteria = criteria.getExecutableCriteria(getSession());
realCriteria.list();


thanks

Jim


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.