I am using Envers to get related entity (say entityB) for a given entity (say entityA) for a given version of enityA. I am comparing revision number of entityA with the related entity ie entityB (numbers will be same if they are in same transaction) and coming out with the revision number of entityB.
Then I query enitityB like:
reader1.createQuery().forRevisionsOfEntity(Bank.class, false, true)
.add(AuditEntity.id().eq(id))
.add(AuditEntity.revisionNumber().eq(entityRevisionNum))
.getSingleResult();
But I get the exception posed below. I've also tried: reader1.find(classVar, id, entityRevisionNum);
but it didn't work.
Here is the stack trace. Does anybody have any idea what caused this exception?
org.hibernate.envers.exception.AuditException: This criterion can only be used on a property that is a relation to another property. at org.hibernate.envers.query.criteria.RelatedAuditExpression.addToQuery(RelatedAuditExpression.java:53) at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:81) at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:104) at org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap(OneToOneNotOwningMap per.java:74) at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:117) at org.hibernate.envers.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:66 ) at org.hibernate.envers.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:66 ) at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:93)
at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:126) at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:104)