Hi everyone, I have a class called Classroom and a Class called Pupil. Classroom has a list of pupils and Pupil has a reference to its parent Classrom.
@Entity
@Audited
public class Classroom {
@OneToMany
private List<Pupil> pupils;
// getters and setters
}
@Entity
@Audited
public class Pupil {
@ManyToOne
private Classroom classroom;
// getters and setters
}
This is the situation: If I create a Classroom, add some Pupils to its list (having cascade all in the list of pupils) and then save, envers create the revision of both classroom and pupils. The problem is when I want to save a pupil indicating which is its classroom (that already exists). In this case, the revision is only created for the pupil and the classroom never notices of this change. If I retrieve the classroom revision after saving a pupil, the list comes empty.
Is there a way to save a Pupil and make the Classroom know that one of its son has changed/added?
I read something about @AuditMappedBy but I could not figure out how it works (and if that solves my problem).
Thanks a lot for your help!
Alberto