0

JaVers users,

I try to understand the basics of a JaVers compare, but can't figure it out!

I've created a very basic MyObject class like below:

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;
    }
}

I create two MyObject's like:

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

Next I do a:

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

The output looks like:

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

My question is what is the exact meaning of ObjectRemoved in this output? Was not able to find any documentation on this, sorry!

Regards, Gerard

g.verhaag
  • 139
  • 3
  • 11

1 Answers1

0

NewObject means that an object exists only on the right side of a diff. ObjectRemoved - only on the left. Since you have mapped your class as Entity, MyObject(1) and new MyObject(2) are two different objects so you cant compare them. Try to map MyObject as ValueObject

Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14