Hi all.
I need to know how can I set Hibernate (...) to achieve the following issue:
I have a bidirectional (composition) one-to-many association (a.bs is a Set<B> object and b.a is a A object). When I load "a" from DB and I update one of its "bs" I need Hiernate intercept A entity when saveOrUpdate A.
Code:
Code:
public class A {
Set<B> bs = new HashSet<B>();
// ... other fields and setters/getters
}
public class B {
A a = null;
// ... other fields and setters/getters
}
Use case:
Code:
A a = load("idA"); // load A from DB
B b = s.getBById("idB"); // get a B element of A
b.setName("blablabla"); // update a field of B
saveOrUpdate(a); // persist A entity with its Bs (including modified B)
The change is performed because the (mini)model has been annotated properly.
The problem is that my interceptor only detects the change in B entity, but not A. I need to detect A change because I need to update audit info.
Other point of view is: I need to get A entity via B and update it. In fact, I can get A from B, but the change is not persisted...
Do you know the problem?
Any idea?
Thanks!