I want to use an alias in the SQLRestriction in the subcriteria
Criteria c1 = dao.getSession().createCriteria(Parent.class,"p") .createCriteria("p.child", "c", Criteria.LEFT_JOIN) .add(Restrictions.sqlRestriction("c.address ilike 'Address%'")); print(dao, c1);
The SQL that gets generated is as follows ----------------------------------------- select this_.id as id3_0_, this_.address as address3_0_, this_.phone as phone3_0_, this_.firstName as firstName3_0_ from Parent this_ left outer join Child this_1_ on this_.id=this_1_.id where c.address ilike 'Address%'
But I am expecting the below sql so that i can use alias in my where clause.
select this_.id as id3_0_, this_.address as address3_0_, this_.phone as phone3_0_, this_.firstName as firstName3_0_ from Parent this_ left outer join Child c on this_.id=this_1_.id where c.address ilike 'Address%'
can someone help me with the createCriteria which can help me achieve the SQL?
Thanks a million.
-Vidhya
|