I'm trying to use Criteria to implement adhoc queries on tables that have multi-tiered relationships.
Code:
Criteria c = session.createCriteria( CaseReview.class );
c.createAlias( "reviewCase" , "reviewCase");
c.createAlias( "reviewCase.studentInformation" , "reviewCasestudentInformation");
c.add( Restrictions.or( Restrictions.ilike("reviewCasestudentInformation.lastName" , "%e%" ), Restrictions.ilike( "reviewCasestudentInformation.firstName" , "%e" )));
c.list();
Where my studentinformation entity has a firstName and lastName attributes, my CaseReview has a reviewCase entity, and my reviewCase entity has a studentInformation attribute.
I end up getting a
Code:
org.hibernate.QueryException: could not resolve property: reviewCasestudentInformation of: CaseReview
which doesn't make any sense to me. The exactly same alias works fine when using the Order api
Code:
// This code works absolutely fine after creating the aliases above
sortOrder = Order.asc("reviewCasestudentInformation.lastName");
criteria.addOrder(sortOrder);
c.list();
I'm about ready to give up. Any suggestions?