Javers SpringBoot integration QueryBuilder byInstanceId returns empty result

60
August 13, 2019, at 9:20 PM

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:

  1. run the service like usual ./gradlew organization-structure-sql:bootRun
  2. create new person

     POST http://localhost:8080/view/person
     {
         "id": 1,
         "firstName": "Yang",
         "lastName": "Huajie",
         "sex": "MALE",
         "salary": 22,
         "position": "DEVELOPER"
     }
    
  3. update it, change any property

  4. 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));
    
  5. it should be showing some data, then restart the service. or force stop it and run number 1.
  6. get the same snapshots again by running number 4, and it should be showing empty result. unless i insert new data, the newly inserted data will be returned.

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.

Answer 1

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)

READ ALSO
Weird hang which can be resolved by installing JDK

Weird hang which can be resolved by installing JDK

My java application hangs frequentlyThe timing is random

55
JavaFx how to avoid window freezing/not responding when running thread like api [on hold]

JavaFx how to avoid window freezing/not responding when running thread like api [on hold]

When I tried to post to an API which is inside on the thread and run it, the whole window freezes even if I put the thread on the other windowWhat I want is even the thread is running I want to access the window

41
Puppeteer: page.goto(url) keeps loading as about:blank

Puppeteer: page.goto(url) keeps loading as about:blank

I tried to crawl the html using puppeteerBut it failed because the url is fixed as js rendered

52
Splitting array of days into months

Splitting array of days into months

I have an array of daily requirementsThe first element in the array represents a start date

71