0

JaVers 用户,

我试图了解 JaVers 比较的基础知识,但无法弄清楚!

我创建了一个非常基本的 MyObject 类,如下所示:

public class MyObject {

    @Id
    private int id;
    private String name;
    private String remark;

    public MyObject() {
        id=-1;
        name = "";
        remark = "";
    }

    public MyObject(int id)
    {
        this.id = id;
        name = "";
        remark = "";
    }

    public MyObject(int id, String name, String remark) {
        this.id = id;
        this.name = name;
        this.remark = remark;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}

我创建了两个 MyObject 之类的:

MyObject firsto = new MyObject(1);
MyObject secondo = new MyObject(2);

接下来我做一个:

Diff diff = javers.compare(firsto,secondo);
System.out.println(diff);

输出如下所示:

Diff:
1. NewObject{globalId:'mypackage.MyObject/2'}
2. ObjectRemoved{globalId:'mypackage.MyObject/1'}

我的问题是这个输出中 ObjectRemoved 的确切含义是什么?无法找到任何有关此的文档,抱歉!

问候,杰拉德

4

1 回答 1

0

NewObject 表示一个对象仅存在于差异的右侧。ObjectRemoved - 仅在左侧。由于您已将您的类映射为实体,MyObject(1)并且 newMyObject(2)是两个不同的对象,因此您无法比较它们。尝试将 MyObject 映射为 ValueObject

于 2017-04-05T16:03:16.010 回答