Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11558

Envers Query API throws NullPointerException when providing a non-audited entity class.

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.11, 5.1.4, 5.2.8
    • Fix Version/s: 5.2.9
    • Component/s: hibernate-envers
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      When using a query API such as:

      auditReader.createQuery().forRevisionsOfEntity( SomeNonAuditedEntity.class, false, false )
        .add( AuditEntity.property( "someProperty.someNested" ).eq( someValue ) )
        .getResultList();
      

      will cause a `NullPointerException` when attempting to locate relation information.

      java.lang.NullPointerException
      	at org.hibernate.envers.internal.entities.EntitiesConfigurations.getRelationDescription(EntitiesConfigurations.java:98)
      	at org.hibernate.envers.query.criteria.internal.CriteriaTools.getRelatedEntity(CriteriaTools.java:44)
      	at org.hibernate.envers.query.criteria.internal.SimpleAuditExpression.addToQuery(SimpleAuditExpression.java:45)
      	at org.hibernate.envers.query.internal.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:89)
      	at org.hibernate.envers.query.internal.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:93)
      

      The query API should likely throw a more relevant exception such as:

      QueryException: Cannot query audit history on a non-audited entity [%s].
      

        Attachments

          Activity

            People

            • Assignee:
              crancran Chris Cranford
              Reporter:
              crancran Chris Cranford
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: