javers | JaVers - object auditing and diff framework for Java | JSON Processing library
kandi X-RAY | javers Summary
kandi X-RAY | javers Summary
JaVers is the lightweight Java library for auditing changes in your data. We all use Version Control Systems for source code, so why not use a specialized framework to provide an audit trail of your Java objects (entities, POJO, data objects)?.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Extracts a snapshot from a JSON representation
- Returns the set difference between the two sets
- Deserialize a snapshot state
- Returns a list of property names that are different from the previous snapshot
- Applies mapping function to each element in the source array
- Applies a mapping function to each value in the source multiset
- Returns an unmodifiable multimipet with the given map function
- Sets properties
- Package private method
- Applies mapping function to each element of the source array
- Serializes the snapshot to JSON
- Calculates a PropertyChange based on the given pair
- Calculate changes
- Searches for changes created
- Deserialize a JSON value change
- Build a list of concrete type arguments
- Deserialize a JSON element
- Calculate multiset changes
- Deserializes from json
- Returns a String representation of the properties
- Apply query parameters to select properties
- Decodes a property
- Converts JsonElement to a multimap
- Serialize to JSON
- Calculates changes
- Queries for all shadows in the given query
javers Key Features
javers Examples and Code Snippets
@Bean
public AuthorProvider provideJaversAuthor() {
return new SimpleAuthorProvider();
}
Community Discussions
Trending Discussions on javers
QUESTION
If I commit the same entity twice, the first time with changes and the second time without any changes, I receive a Commit with a CommitId both times. The first one holds the changes, the second has a empty changes list.
Is this behaviour intentional? I would expect to not get a CommitId for the second commit as there is no change and also no commit in the database. I got around the issue by checking if the changes list is not empty.
My Repository
...ANSWER
Answered 2022-Apr-02 at 10:43This is how Javers works, you can have empty commit (without snapshots), but you can't have no commit. This design is expressed in Javers API, when you call javers.commit()
you get a Commit
object and not Optional
.
QUESTION
When using Javers and Spring Boot applications (with MongoDB) in distributed environments, I get incorrect auditing snapshots.
How to recreate (assuming we have 2 servers) -
- Update an existing Document by sending a request on server 1
- Update the same Document by sending a request on server 2
- Update the same Document again by sending a request on server 1
The last generated auditing data will contain previousValue as it was on request 1 and the currentValue as it is on request 3.
Currently, I have fixed the issue by disabling javers cache by setting the following property javers.snapshotsCacheSize=0.
Is there any way to keep javers cache consistent in distributed environments?
...ANSWER
Answered 2022-Feb-20 at 07:44There is no such way. Javers uses local cache only. I didnt tested it but I dont think that adding a distributed cache layer would significantly speed things up. It would add additional overhead. But if you are interested in contributing that feature - we can talk about it here https://github.com/javers/javers/discussions
QUESTION
I am working on a rest backend using spring boot/jpa. I also use javers to audit my JpaRespositories.
I am not entirely sure, if javers is intended for this purpose, but in addition to auditing my jpa entities i would also like to be able to edit the history.
For example, i would like to get a Shadow-Object from a certain date:
...ANSWER
Answered 2021-Nov-03 at 17:19You can't do it. Javers' Snapshots are immutable by design.
QUESTION
my pom.xml file:
...ANSWER
Answered 2021-Sep-15 at 03:45You have told Maven that your project is only a POM artifact (which doesn't have code or need jars):
QUESTION
I was using Javers for mongoDB document versioning with springboot. It provides essential functionalities for versioning such as separate history collection called jv_snapshots
, changed field list in Entity
or ValueObject
model for their versions.
But I found an issue relevant to valueObjects, but not entities. As you know, the difference between entity and valueObjects is the unique id that identifies the entity, but valueObjects don't have such Id to identify their versions. Refer the following examples as I observed this issue in my use case.
Let's take the following Entity and valueObject models for versioning.
Invoice.java
...ANSWER
Answered 2021-Aug-29 at 08:23If you don't care about ordering, change List
to Set
in the model. Alternatively, you can configure Javers to use the ListCompareAlgorithm.AS_SET
feature.
In Spring Boot, you can enable it by setting javers.algorithm: AS_SET
in your application.yml
.
see https://javers.org/documentation/spring-boot-integration/#javers-configuration-properties
QUESTION
This is a really odd error that I am getting while doing a maven build. I am encountering an error like this:
...ANSWER
Answered 2021-Jun-29 at 13:28I feel really silly about this now. It turns out someone uploaded something to our internal artifactory for commons-lang that was not really commons-lang. No idea how that happened, but it was a never-ending source of frustration for me. If anyone else ever sees something that doesn't make sense like this, compare the size of the jar in your .m2 folder with one downloaded directly from maven central. That would have saved me a lot of time.
QUESTION
I am using the following code to retreive the changes made to a version in my API response
...ANSWER
Answered 2021-Jun-18 at 10:57List changes = javers.findChanges(jqlQuery.build()).groupByCommit();
ValueChange valueChange = (ValueChange)changes.get(0).get().get(0);
String property = valueChange.getPropertyName();
Object originalValue = valueChange.getLeft();
Object newValue = valueChange.getRight();
QUESTION
I have two maps that can be modified by different authors. In this particular use case, I have a limitation where I shouldn't use POJOs or Domain objects, only a Maps.
...ANSWER
Answered 2021-Apr-02 at 08:50You can compare two top level Maps but you cant commit a map to Javers Repository (exception should be thrown) because Maps have no identifiers.
QUESTION
I have such class:
...ANSWER
Answered 2021-Mar-18 at 19:35You can use Custom Types and CustomPropertyComparator
. See the javadoc for CustomType
:
Custom Types are not easy to manage, use it as a last resort, only for corner cases like comparing custom Collection types.
JaVers treats a Custom Type as a black box
and doesn't take any assumptions about its content or behaviour.
It's a "not modeled" type, somehow similar to unbounded wildcard
Objects of Custom Type are compared by a CustomPropertyComparator
.
Registering this comparator is the only way to map a Custom Type.
Custom Types are serialized to JSON using Gson defaults.
see JaversBuilder#registerCustomType(Class, CustomPropertyComparator)
QUESTION
I have 2 classes:
...ANSWER
Answered 2021-Mar-07 at 19:01I solved my problem. it was enough to overwrite the interface CustomPropertyComparator.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install javers
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page