How do you select a column using Hibernate?

前端 未结 3 1634
北荒
北荒 2020-12-25 10:55

I would like to select a single column instead of a whole object, using Hibernate. So far I have this:

 List firstname = null;

 firstname = ge         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-25 11:17

    You can set the Projection for this like:

    .setProjection(Projections.property("firstname"))
    

    With this you can only get the firstname in return.

    I have found another link on stack with the same scenario. Hope this will also help How to use hibernate criteria to return only one element of an object instead the entire object?

提交回复
热议问题