I've an entity where one field B might depend on field A (just for certain cases). To make sure that they are both updated if needed (to avoid that someone else using the entity forgets about the dependency) I tried something like this:
public void setA(A a) {
this.a = a;
if (condition) {
this.b = someCalculation(a);
// setB(someCalculation(a)); Doesn't work either!
}
}
The code is executed and the value for B is filled correctely. However, B is not persisted.
Is somthing like this just not possible? Why isn't hibernate aware of the change of B?
Thanks in advance,
Alex