I have a object with below relationship
public class A { @Id @SequenceGenerator(name = "ID_GENERATOR", sequenceName = "Id_SEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_GENERATOR") @Column(name = "id") private BigDecimal id;
@OneToMany(mappedBy = MST, orphanRemoval = true, cascade = { CascadeType.ALL}) @OrderBy("id DESC") private List<B> b = new ArrayList<B>(); @Column(name = "name") private String name;
}
When I modify class A’S attribute SAY name attribute and say dao.persist(A) using JPA entitymanager then onFlushDirty()[overridden in my Hibernate interceptor] is getting invoked for B object even when it is not modified
I am not understanding why hibernate is treating List<B> objects to be dirty when I am trying to save the parent object A.
In short when i persist Parent A then all childrens are also marked for update .i.e Hibernate Interceptors onFlushDirty() is invoked even when they are not modified
|