最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring boot - How to maintain a complete multi-entity history with Javers (no soft-delete)? - Stack Overflow

programmeradmin4浏览0评论

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"
  • ProjectAModuleB is many-to-many.
  • ModuleBTaskC 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?

发布评论

评论列表(0)

  1. 暂无评论