Add a method to fetch Snapshots or Changes by (multiple) local ID without the need of TypeName or Class
See original GitHub issueRequirement
I am working on a project that involves Entities (saved in Mongo) to be associated with IDs as properties. For example, A User has addressId that references Address being a separate Entity since it follows a separate lifecycle. All the changes to these entities are being audited using Javers in a central repository (through a Microservice). As a part of the functionality, I need to display consolidated audit logs on a Web UI. Trouble is the fetching of the audits for multiple entities of different types. Since the methods to build a JqlQuery take either a TypeName or a Class along with the instance IDs, the clients always need to have more knowledge than they should have to fetch the logs.
Describe the solution you’d like
Since our entities have unique IDs (UUID), there should be no need of supplying the TypeName or the entity Class to fetch the CdoSnapshots or the Changes since the clients have access to the main entity and the IDs of the associated entities that they can use directly. At the same time, there could be a method that would accept multiple instanceIds without the Class or TypeName. Either this or there should be scope to supply a custom FilterDefinition to the QueryBuilder to allow defining a custom matcher where we could use different criteria for matching a CdoSnapshot or Changes.
Describe alternatives you’ve considered
One of the alternatives we have right now is to annotate each and every entity with a @TypeName across microservices and the client knowing all these TypeName for each of the properties of the main entity to be able to fetch the audits. This is a huge overkill. Even with that, there is no way of fetching the audits for multiple entities and instanceIds together limited by pages.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Hey @bartoszwalacik! Thanks for the response. I will spend some time in verifying if the existing indexes would work with this. I will also discuss the changes that might be required before proceeding.
I second this.
In our case we have a Spring boot based library that can be used in multiple services. One of the things it supplies is Javers - but being an external library it won’t know anything about all the entities that are persisted in the application it is used in.
But what we do have is unique ids that’s is prefixed with the data type, fx. a
Contactcould have the idcont-1234,Notecould havenote-1234. In other words our id’s are unique AND carry the type in them.Therefore it could be awesome to be able to simply get its changes by
QueryBuilder.byInstanceId("cont-1234").What we need to do now is to add
@TypeNameto all entities with the type part of our id(fx.@TypeName("cont")) and then retrieve them by extracting the type part from the id before resolving: