Getting fewer columns with hibernate

前端 未结 3 1869
清酒与你
清酒与你 2021-01-05 13:20

I have a table with 11 columns, but I need to get only 2 of them in my application, I\'m using spring/hibernate/DAO combination. For now I have a domain class which includes

3条回答
  •  逝去的感伤
    2021-01-05 13:42

    Try:

    SELECT myEntity.one, myEntity.two FROM MyEntity myEntity
    

    You can even do :

    SELECT new MyEntityDescription(myEntity.one, myEntity.two) FROM MyEntity myEntity
    

    to get a list of entity descriptions.

提交回复
热议问题