请解释一下可插入=false和updatable=false在参考JPA@Column注释
2022-08-31 06:36:22
如果一个字段是注释的,这是否意味着您不能插入值或更改现有值?你为什么要这样做?insertable=false, updatable=false
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(mappedBy="person", cascade=CascadeType.ALL)
private List<Address> 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;
}