"QueryException: could not resolve property ..." failure for association property in Hibernate Envers in EAP
Issue
-
An
AuditQueryfails withorg.hibernate.QueryException: could not resolve property: employee of: support.hibernate.entity.Task_AUD [select e__, r from support.hibernate.entity.Task_AUD e__, org.hibernate.envers.DefaultRevisionEntity r where e__.REVTYPE <> :_p0 and e__.employee.title = :_p1 and e__.originalId.REV.id = r.id order by e__.originalId.REV.id asc] at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) ... at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1739) at org.hibernate.envers.tools.query.QueryBuilder.toQuery(QueryBuilder.java:226) at org.hibernate.envers.query.impl.AbstractAuditQuery.buildQuery(AbstractAuditQuery.java:92) at org.hibernate.envers.query.impl.AbstractAuditQuery.buildAndExecuteQuery(AbstractAuditQuery.java:98) at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:112) at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:106) ... -
The
AuditQueryhas a restriction involving a property of an associated instanceAuditQuery query = auditQueryCreator.forRevisionsOfEntity(Task.class, false, false); query.add(AuditEntity.property("employee.title").eq("Engineer")); ... -
The association involves entity classes like the following
@Entity @Audited public class Task { ... @ManyToOne private Employee employee; ... } @Entity @Audited public class Employee { ... private String title; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "employee_name") private List<Task> tasks; ... }
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6
- Hibernate / Envers 4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
