Hi,
we have to classes Person and Address which have a bidirectional One-To-One relation (optional = false).
Code:
public class Person {
private Address address;
@OneToOne(optional = false)
public Address getAddress() {
return address;
}
}
public class Address {
private Person person;
@OneToOne(optional = false, mappedBy = "address")
public Person getPerson() {
return person;
}
}
A persons Address might change very often in our application. Of course we want user A to be informed by Hibernate that another user has changed an address when A tries to change the same address. Therefore we use a version column and optimistic locking.
Nevertheless when A tries to delete a person it should be allowed no matter whether his address has changed since last read or not. In other words we want to ignore the version number of the persons address when deleting this person.
How would you do this in Hibernate?
Thanks in advance,
Ole