hibernate fetch specific column from database using criteria

左心房为你撑大大i 提交于 2019-12-11 05:49:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!