Я работаю на примере Spring Boot Javers .В этом примере значение свойства horsePower
изменилось.Теперь я хочу знать, какое было старое значение и какое текущее.
db.getCollection('jv_snapshots').find({})
/* 1 */
{
"_id" : ObjectId("5d0602e476e79c53f06f1d6b"),
"commitMetadata" : {
"author" : "unauthenticated",
"properties" : [],
"commitDate" : "2019-06-16T14:20:44.465",
"commitDateInstant" : "2019-06-16T08:50:44.465Z",
"id" : NumberLong(1)
},
"globalId" : {
"valueObject" : "com.example.model.Car"
},
"state" : {
"horsePower" : NumberLong(670),
"year" : "2015",
"model" : "488",
"id" : "5d0602e476e79c53f06f1d6a",
"brand" : "Ferrari"
},
"changedProperties" : [
"horsePower",
"year",
"model",
"id",
"brand"
],
"type" : "INITIAL",
"version" : NumberLong(1),
"globalId_key" : "com.example.model.Car/"
}
/* 2 */
{
"_id" : ObjectId("5d0602e476e79c53f06f1d6d"),
"commitMetadata" : {
"author" : "unauthenticated",
"properties" : [],
"commitDate" : "2019-06-16T14:20:44.574",
"commitDateInstant" : "2019-06-16T08:50:44.574Z",
"id" : NumberLong(2)
},
"globalId" : {
"valueObject" : "com.example.model.Car"
},
"state" : {
"horsePower" : NumberLong(800),
"year" : "2015",
"model" : "488",
"id" : "5d0602e476e79c53f06f1d6a",
"brand" : "Ferrari"
},
"changedProperties" : [
"horsePower"
],
"type" : "UPDATE",
"version" : NumberLong(2),
"globalId_key" : "com.example.model.Car/"
}
Я разработал такой код, но он не работает хорошо.
@Autowired
private Javers javers;
private void withJavers() {
List<Change> changes = javers.findChanges(QueryBuilder.byClass(Car.class)
.withNewObjectChanges().build());
System.out.println("Printing the flat list of Changes :");
changes.forEach(change -> System.out.println("- " + change));
}