问题
I want to fetch specific column from database by using criteria.
select name, lastname from sssssss
Please reply
Thanks in advance.
回答1:
you need to use the projecttion Class.. check this documentation for details..
List results = session.createCriteria(SSSS.class)
.setProjection( Projections.projectionList()
.add( Projections.property("name") )
.add( Projections.property("lastName") )
)
.list();
来源:https://stackoverflow.com/questions/6715946/hibernate-fetch-specific-column-from-database-using-criteria