Here is my use case
I have two entities : Personn and Email (a @OneToMany relation). Both of them are audited.
First I create a new Personn, with an Email (=
I have been unable to make the custom post update listener solution work. addCollectionChangeWorkUnit doesn't seem to exist until hibernate 4.1 where it is marked private. EnversPostUpdateEventListenerImpl seems to appear at some point in hibernate 4.0
I solved my problem by adding a hidden lastUpdated date field on my equivalent of your A entity.
@Entity
public class A {
private Date lastModified;
@OneToMany(mappedBy = "a", cascade = CascadeType.ALL )
private List blist;
public void touch(){
lastModified=new Date();
}
}
In the related entities (like you B field), I added the following :
public class B {
@ManyToOne
private A a;
@PreUpdate
public void ensureParentUpdated(){
if(a!=null){
a.touch();
}
}
}
This ensures that a revision is added to A whenever a revision is added to B even though it requires custom code in many entities.