We want to track changes in a large system, but I'll simplify it to three example JPA entities: ProjectA, ModuleB, and TaskC. Here’s a minimal schema:
@Entity
public class ProjectA {
@Id
private Long id;
private String projectName;
@ManyToMany
private Set<ModuleB> modules = new HashSet<>();
}
@Entity
public class ModuleB {
@Id
private Long id;
private String moduleName;
// many-to-many back to ProjectA
@ManyToMany(mappedBy = "modules")
private Set<ProjectA> projects = new HashSet<>();
// one-to-many to TaskC
@OneToMany(mappedBy = "parentModule")
private Set<TaskC> tasks = new HashSet<>();
}
@Entity
public class TaskC {
@Id
private Long id;
private String taskDescription;
@ManyToOne
private ModuleB parentModule;
}
// all the repositories are annotated with "@JaversSpringDataAuditable"
- ProjectA ↔ ModuleB is many-to-many.
- ModuleB → TaskC is one-to-many.
- ModuleB and TaskC can also be changed by other parts of the system, not just from
ProjectA
code. - No soft-delete; physically removed entities are gone from the DB.
Goal: Use JaVers to produce a single, root-oriented history from ProjectA
:
- Show changes to A itself (e.g.,
projectName
). - Track additions/removals of B references (including B’s that were physically deleted).
- Show any TaskC updates in B, even if B was later unlinked or removed from A.
I want something like getFullHistory(ProjectA id)
to reconstruct a timeline of all changes that ever affected A, its B’s, and those B’s C’s—regardless of whether B or C still exists. No soft-delete is available, so I'm concerned about references to vanished entities.
Question: What are the best practices to achieve a complete history in JaVers without soft-delete, such that old relationships and data remain visible in the audit?