0

I have an entity which extends from anothers, like that:

public class House extends Building{
 public Integer idHouse
}

public class Building extends Structure{
}

public class Structure {
 public Integer field1;
}

I need to audit changes in House objects but I don't want to include Structure.field1 field. I tried this:

String skippedFields = ["field1"];
        EntityDefinition houseEntity =
                EntityDefinitionBuilder.entityDefinition(House.class)
                .withIdPropertyName("idHouse")
                .withIgnoredProperties(Arrays.asList(skippedFields))
                .build();

Javers javers = JaversBuilder.javers()
 .registerEntity(expedienteEntity)
    .registerJaversRepository(sqlRepository).build();

But it seams to ignore the "IgnoeredPropertied". I also tried to map the structure class, but I can't because it doesn't have an id.

Any ideas on how can I ignore field1? Thx!

Nuria
  • 176
  • 2
  • 11

1 Answers1

0

Can you show a failing test case for that issue?

I wrote the test (groovy) and everything looks fine (your Entity has only one property - idHouse):

class StackCase extends Specification {

    class Structure {
        public Integer field1
    }

    class Building extends Structure{
    }

    class House extends Building{
        Integer idHouse
    }

    def "should use IgnoredProperties "(){
      given:
      def houseEntity =
              EntityDefinitionBuilder.entityDefinition(House)
                      .withIdPropertyName("idHouse")
                      .withIgnoredProperties(["field1"])
                      .build()

      def javers = JaversBuilder.javers()
              .registerEntity(houseEntity).build()

      def entityType = javers.getTypeMapping(House)
      println entityType.prettyPrint()

      expect:
      entityType.properties.size() == 1
    }
}

output:

22:16:51.700 [main] INFO  org.javers.core.JaversBuilder - JaVers instance started in 723 ms
EntityType{
  baseType: class org.javers.core.StackCase$House
  typeName: org.javers.core.StackCase$House
  managedProperties:
    Field Integer idHouse; //declared in House
  idProperty: idHouse
}
Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14