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