Reputation: 2755
I'm using JaVers 5.6.3 with Spring Boot 2.1. Saving history is working fine and I also can read object changes.
I use this code:
List<Change> changes = javers.findChanges(jqlQuery.build());
My problem is that the result contains only the commit id, but not the object version. In the database there is a jv_snapshot.version
field, that contains the real object version.
How can I get it in my code?
Upvotes: 0
Views: 658
Reputation: 1515
I don't know if this helps or not but you can get whole entity with its version
First get the shadow and then try to get snapshot from the committed. As given in the code
List<Shadow<YourObject>> shadows= javers.findShadows(QueryBuilder.byInstance(optionalObject.get()).build());
List<CdoSnapshot> changes=javers.findSnapshots(QueryBuilder.byInstanceId(id,YourObject.class).withCommitId(shadow.get(0).getCommitId()).build());
In this way, you can get version of each entity, let me know if you find some better way.
Upvotes: 0
Reputation: 30
You can get the version using snapshot for example:
List<CdoSnapshot> snapshots = javers.findSnapshots(jqlQuery.build());
snapshots.forEach(snapshot -> {
System.out.println(snapshot.getVersion());
});
Upvotes: 1