-->
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: hql query to criteria query
PostPosted: Mon Apr 30, 2007 12:46 pm 
Newbie

Joined: Mon Apr 30, 2007 12:27 pm
Posts: 18
Hi all,

Im having some problems with the left join in the criteria query.

Im trying to join 2 tables by a left join, but I want two restrictions in the join:

I want to get a sql query like this:

"select * from items1 left join items2 (on items1.id = items2.items1_id and items2.property = 1) "

I know how to do it with hql, and it would be something like this:

"from items1 it1 left join items2 it2 with it2.property = 1"

but when I try with criteria query, my restriction is always outside the join clause, and it affects the whole query.

Criteria crit = sess.createCriteria(Items1.class);
crit.createAlias("items2","items2",CriteriaSpecification.LEFT_JOIN).add( Restrictions.eq("items2.property", 1) );
crit.list();

Does anyone know how to do that the restriction only affects the join?

Thanks in advance, Javier Rivas.


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.