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

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -