如何使用 Javers 区分同一实体 class 但具有不同 Id 的两个对象
How to use Javers to diff two object of same entity class but with different Id
来自Javers.org
Each Entity instance has a global identifier called InstanceId. It consists of a class name and an ID value.
Comparing strategy for Entity references is based on InstanceId and for Entity state is property-by-property.
Entity can contain ValueObjects, Entity references, Containers, Values and Primitives.
现在我想比较两个实体对象,实际上是同一个对象的两个版本,但是Javer会直接判断它们是旧对象和新对象。无法比较它们的价值。
@Entity
public class Person {
@Id
private Integer id;
private String name;
private Integer age;
}
PersonOne(1, "汤姆", 20);
PersonTwo(2,"Jerry", 18);
有没有办法比较这两个对象?
您可以告诉 JaVers 将这些对象作为值对象进行比较 (属性-by-属性):
javersBuilder.registerValueObject(Person.class)
来自Javers.org
Each Entity instance has a global identifier called InstanceId. It consists of a class name and an ID value.
Comparing strategy for Entity references is based on InstanceId and for Entity state is property-by-property.
Entity can contain ValueObjects, Entity references, Containers, Values and Primitives.
现在我想比较两个实体对象,实际上是同一个对象的两个版本,但是Javer会直接判断它们是旧对象和新对象。无法比较它们的价值。
@Entity
public class Person {
@Id
private Integer id;
private String name;
private Integer age;
}
PersonOne(1, "汤姆", 20);
PersonTwo(2,"Jerry", 18);
有没有办法比较这两个对象?
您可以告诉 JaVers 将这些对象作为值对象进行比较 (属性-by-属性):
javersBuilder.registerValueObject(Person.class)