java - 即使它们相同,也将属性添加到更改列表中。(Javers)
问题描述
我有一个 POJO 如下
class Employee{
private int id;
private String name;
private String profession;
private int experince;
public Employee(int id, String name, String profession, int experience){
this.id = id;
this.name = name;
this.profession = profession;
this.experience = experience;
}
我有两个要比较的对象
Employee emp1 = new Employee(1, "John Doe", "Architect",10);
Employee emp2 = new Employee(2, "Michael", "Developer",10);
我比较两个对象并获得更改
Diff diff = javers.compare(emp1,emp2);
List<Change> changes = diff.getChanges();
有了这个,我得到(id,name,professional)作为改变的属性,它们各自的左值和右值。
有什么方法可以将“经验”也包含在左右值相同的更改中?
解决方案
简短的回答是否定的,更改视图报告,好吧,只是改变了一些事情。也许您需要快照视图或阴影视图?
- 影子是从快照恢复的域对象的历史版本。
- 变化代表两个对象之间的原子差异。
- 快照是作为属性:值映射捕获的域对象的历史状态
见https://javers.org/documentation/jql-examples/#data-history-views
推荐阅读
- c# - 无法使用正则表达式否定单词组合
- linux - 用出现的字符串替换文本文件中的字符串
- sql - 关于简单 SQL 选择的建议
- javascript - 从 django 网站中的 javascript 发送到 views.py 的数据不正确
- python - 如何成功终止通过子进程运行创建的子进程
- java - 我无法从模块化 Maven 项目(在 IntelliJ 中)的测试目录中运行我的应用程序
- react-native - 使用 react-native-scrollable-tabview 获取数据
- excel - 如何在 VBA 中的 IF 语句中的 Match 语句中对 2 个部分文本(一个或另一个)使用 OR 语句?
- arrays - MongoDB 在具有多个嵌套级别的数组和对象中查找
- bash - bash 脚本中 =<(...) 的语法