@javax.persistence.Column( updatable=false )

前端 未结 2 1636
小鲜肉
小鲜肉 2021-01-12 07:04

If I define a field as non-updatable, does that mean that the field can\'t be updated at all, ever? What I\'d like to do is prevent the field from getting updated when I sav

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 07:50

    As documented, setting updatable=false affects only SQL UPDATE statements generated by persistence provider:

    Whether the column is included in SQL UPDATE statements generated by the persistence provider.

    You are still able to write such an SQL update statement that will update values in this column. This functionality defined in JPA specification, and is not Hibernate/MySQL specific.

提交回复
热议问题