ObjectRemoved(JaVers)类型的变化是什么意思?

时间:2017-04-04 13:08:08

标签: auditing javers

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的确切含义是什么? 对不起,找不到任何文件,对不起!

此致 杰拉德

1 个答案:

答案 0 :(得分:0)

NewObject意味着对象仅存在于diff的右侧。 ObjectRemoved - 仅在左侧。由于您已将类映射为实体,因此MyObject(1)和新MyObject(2)是两个不同的对象,因此您无法比较它们。尝试将MyObject映射为ValueObject