Getting fewer columns with hibernate

前端 未结 3 1894
清酒与你
清酒与你 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:49

    If you never need more than those 2 columns of the table, you could change your hibernate mapping to map only those 2 needed columns to the entity class. Only map those table columns you want to access in your application. Keep in mind, that database constraints on the "ignored" columns can be violated like not null constraints, foreign keys or unique constraints.

提交回复
热议问题