raviraja
raviraja

Reputation: 706

Add property to changes list even if they are same.(Javers)

I have a POJO as below

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

and i have two objects which i want to compare

Employee emp1 = new Employee(1, "John Doe", "Architect",10);
Employee emp2 = new Employee(2, "Michael", "Developer",10);

I compare both the objects and get changes as

Diff diff = javers.compare(emp1,emp2);
List<Change> changes = diff.getChanges();

With this, I get (id, name, profession) as changed properties with their respective left and right values.

Is there any way I can include "experience" also as part of the Changes with left and right values as same?

Upvotes: 0

Views: 878

Answers (1)

Bartek Walacik
Bartek Walacik

Reputation: 3496

Short answer is no, the Changes view reports, well, changed things only. Maybe you need the Snapshots view or Shadows view?

  • Shadow is a historical version of a domain object restored from a snapshot.
  • Change represents an atomic difference between two objects.
  • Snapshot is a historical state of a domain object captured as the property:value map

see https://javers.org/documentation/jql-examples/#data-history-views

Upvotes: 3

Related Questions