spring Javers查询返回空结果

von4xj4u  于 2023-04-04  发布在  Spring
关注(0)|答案(1)|浏览(176)

在我的Mysql DB中,我有审计表:

global_id_pk|local_id|fragment|type_name                                         |owner_id_fk|
------------|--------|--------|--------------------------------------------------|-----------|
           1|3014    |        |de.cc.carorderprocess.models.Car    |           |


snapshot_pk|type   |version|state |changed_properties                                   |managed_type                        |global_id_fk|commit_fk|
-----------|-------|-------|------|-----------------------------------------------------|------------------------------------|------------|---------|
          1|INITIAL|      1|......|.....................................................|de.cc.carorderprocess.models.Car    |           1|        1|
          5|UPDATE |      3|......|[¶   "modifyDate",¶  "nameCar"¶]      |de.cc.carorderprocess.models.Car    |           1|        3|
          6|UPDATE |      4|......|[¶   "modifyDate",¶  "modelCar"¶]    |de.cc.carorderprocess.models.Car    |           1|        4|

但是当我在我的控制器中执行以下操作时:

Javers javers = JaversBuilder.javers().build();

QueryBuilder jqlQuery = QueryBuilder.byClass(Car.class);
List<CdoSnapshot> snapshots = javers.findSnapshots(jqlQuery.build());
logger.info(javers.getJsonConverter().toJson(snapshots));

Car car2 = carRepo.findById(3014l).get();
jqlQuery = QueryBuilder.byInstance(car2);
Changes changes = javers.findChanges(jqlQuery.build());
logger.info(javers.getJsonConverter().toJson(changes));

对于这两种情况,我都得到空数组

3hvapo4f

3hvapo4f1#

尝试

queryBuilder jqlQuery = QueryBuilder.byClass(Car.class);
List<CdoSnapshot> snapshots = javers.findSnapshots(jqlQuery.build());
logger.info(javers.getJsonConverter().toJson(snapshots));

car car2 = carRepo.findById(3014l).get();
jqlQuery = QueryBuilder.byInstance(car2);
Changes changes = javers.findChanges(jqlQuery.build());
logger.info(javers.getJsonConverter().toJson(changes));

相关问题