I'm using springboot integration from this example:
https://github.com/l7777777b/organization-structure
It's my forked example from:
https://github.com/javers/organization-structure
using mysql and recent version of Javers 5.6.3, gradle 5.4.1 and springboot 2.1.6.RELEASE.
First im not sure if its an expected behaviour, but the changes and snapshot return empty result when using QueryBuilder.byInstanceId
, but when using QueryBuilder.byClass
it shows correctly.
QueryBuilder.byInstanceId
can show results for newly inserted data, for existing data (data already on database prior the service started) it seems not getting fetched.
To reproduce it:
./gradlew organization-structure-sql:bootRun
create new person
POST http://localhost:8080/view/person
{
"id": 1,
"firstName": "Yang",
"lastName": "Huajie",
"sex": "MALE",
"salary": 22,
"position": "DEVELOPER"
}
update it, change any property
get snapshots using this code:
QueryBuilder jqlQuery = QueryBuilder.byInstanceId("1", Person.class);
List<CdoSnapshot> changes = javers.findSnapshots(jqlQuery.build());
JsonConverter jsonConverter = javers.getJsonConverter();
System.out.println(jsonConverter.toJson(changes));
But if i change QueryBuilder.byInstanceId(personId, Person.class);
into QueryBuilder.byClass(Person.class);
i can get all result from database correctly, but i only need to search specific id that's why i need to use byInstanceId
.
Its look like id is Integer and you are passing a String value to the
byInstanceId("1")
, could you please try to change it to int and check ex. byInstanceId(1)