Search code examples
hibernate-envers

Envers return QueryException on AuditReaderFactory query composite property


Envers cannot find composite property in Embedded class Audited. I have :

@Embeddable
public class Allocation {

   private Long value;

...
}


@Entity
@Table(name = "payment")
@Audited
@AuditTable(value="payment_allocation")
public class PaymentEntity extends AbstractEntity {

   // All propert is not Audited except Allocation
   @Embedded
   @NotAudited
   private Transaction transaction;

   @Audited
   @Embedded
   private Allocation allocation;
...
}

So when I call :

AuditReaderFactory
            .get(entityManager)
            .createQuery()
            .forRevisionsOfEntity(PaymentEntity.class, true, true)
            .add(AuditEntity.property("allocation.value").eq(1l))
            .getResultList();

I have a

org.hibernate.QueryException: could not resolve property: allocation of: ....PaymentEntity_AUD

I try just "value" and I had same exception.

I want history of all Payments where value was 1L. So, There are something different to access a composite property like when we build a Query?


Solution

  • So, I found solution on : https://hibernate.atlassian.net/browse/HHH-9178

    the name of property not "allocation.value" but "allocation_value".