Is it possible to have immutable fields in Hibernate/JPA?

后端 未结 5 1553
清歌不尽
清歌不尽 2021-02-07 03:00

In our application, we need to have fields that are assignable only once.

At first we thought of encapsulating the fields and making the setters private. However, some q

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 03:47

    Try

    @Column(updatable = false)
    

    From javadoc:

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

提交回复
热议问题