0 Replies Latest reply on Apr 3, 2017 10:15 AM by Sébastien Beaume

    Hibernate envers : composite keys

    Sébastien Beaume Newbie

      Hi,

       

      I have encountered an issue while trying to use envers audit features.

       

      Can envers handle composite key ? If yes, from which version ?

       

      i have this error :

       

      Caused by: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private final long my.package.AbstractBaseEntity.id] by reflection for persistent property [my.package.Customer#id] : 2

        at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:43)

        at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:223)

        at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4601)

        at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4313)

        at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:226)

        at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:276)

        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:455)

        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:153)

        at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:343)

       

       

      Basically, we have one entity with a composite key <long, long>, but it seems that envers tries to save it in the audit table as a <Long,Long> key.

      We are using hibernate 5.0.7.

       

       

      Do you have any idea of how we could overcome this issue ?

       

      Thanks,