Hi, i want to know how i can tell the hibernate API to
not use projection aliases for the restrictions in one query.
ExampleCode:
ProjectionList colProjection = Projections.projectionList();
List<Criterion> colCriterions = new ArrayList<>();
colProjection.add( Projections.property( "pid" ), "pid" );
colProjection.add( Projections.property( "descr" ), "descr" );
colCriterions.add( Restrictions.eq( "pid", 1l ) )
colCriterions.add( Restrictions.like( "descr", "some text", MatchMode.ANYWHERE ) );
Criteria query = session.createCriteria(Some.class);
query.setProjection( colProjection );
for ( Criterion criteria: colCriterions ) {
query.add(criteria);
}
query.setResultTransformer( Transformers.aliasToBean(Some.class ) );
List<Some> = query.list();
The example above wont work, because the Restrictions are putting the alias from the Projections into the WHERE-clause of the query.
So, how do Projections and Restrictions get along? Can i turn off the alias using from Projections?