Please rest assure that I did some search trying to understand about this as much as possible, but most of the community posts are about implementation instead of explanation. I guess I just dont understand it correctly, but if a field is annotated insertable=false, updatable=false
, doesnt it mean that you cannot insert value nor change the existing value? Why would u want to do that?
EDIT: Do you mean something like this BalusC?
@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;
}