jpa - Please explain about: insertable=false, updatable=false -


If a field is annotated, then insertable = false, updatable = false , it means Is not that you can not include the value and can not change the existing value? Why do you want to do this?

@ Entity Public Sector Person {@Id @ generatedValue (strategy = GenerationType.auto) Private Long ID; @OneToMany (mapped = "person", cascade = cascade type.AL) Private list & lt; Address & gt; Addresses; } Entity Public Class Address {@Id @GeneratedValue (strategy = GenerationType.AUTO) Private Long ID; @ManyToOne @JoinColumn (name = "ADDRESS_FK") @column (insertable = false, updatable = false) Private person person; }

You will do this when creating responsibility / questions Updating the associated entity is not in the current unit as you have a person and a address you insertable = false, updatable Unit = from @OneToMany to the person unit unit, just because it address < / Code> is not the responsibility of the entity person to create or update It's another way for them.


Comments