Search code examples
javers

Automatically Ignore @OneToMany, @ManyToOne


I'm successfully logging entities with Javers, but for every entity I have to put @DiffIgnore and @ShallowReference to ignore fields mapped with @OneToMany, @ManyToOne, etc. I'm trying to configure on JaversBuilder, but without success. Is there a way to configure on Javers to automatically ignore properties mapped with these annotation? Or only take properties with @Column annotation?

I read these, and tried to follow some of the answers, but it didn't worked either.

Javers - DiffIgnore on bidirectional OneToMany

Javers default ignore instead of default include


Solution

  • There is no way to order JaVers to ignore a field when it has a specific annotation. JaVers doesn't read all annotations in your classes.

    You can implement a annotation scanner on your side and then register your EntityDefinitions in JaversBuilder:

    public JaversBuilder registerEntity(EntityDefinition entityDefinition)