hql - Hibernate Criteria: Projection with TransferObject -


how convert hql code below hibernate criteria query?

select     new com.project.to.personto(         person.firstname,         person.lastname     )     person person 

try below :-

criteria criteria = session.createcriteria(person.class); criteria.setprojection(projections.projectionlist().add(projections.property("firstname"), "firstname") .add(projections.property("lastname"), "lastname"))                     .setresulttransformer(new aliastobeanresulttransformer(personto.class)); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -