Hibernate Criteria Query to get specific columns

前端 未结 5 1593
情深已故
情深已故 2020-11-29 20:43

I am using Criteria Query in my code. It always fires select * from ...

Instead I want to neglect one column(field) from my query as that field have lar

5条回答
  •  醉话见心
    2020-11-29 20:48

    You can map another entity based on this class (you should use entity-name in order to distinct the two) and the second one will be kind of dto (dont forget that dto has design issues ). you should define the second one as readonly and give it a good name in order to be clear that this is not a regular entity. by the way select only few columns is called projection , so google with it will be easier.

    alternative - you can create named query with the list of fields that you need (you put them in the select ) or use criteria with projection

提交回复
热议问题