Hi all,
To make it short: hibernate doesn't support projections and query by example? I found this post:
The code is this:
User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr))
Like the other poster said, The generated sql keeps having a where class refering to just y0_= ? instead of this_.city.
I already tried several approaches, and searched the issue tracker but found nothing about this.
I even tried to use Projection alias and Transformers, but it does not work:
User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr)).setResultTransformer(Transformers.aliasToBean(User.class));
Has anyone used projections and query by example ?