1 Reply Latest reply on Nov 12, 2009 8:52 AM by adamw

    Envers-Bug when restricting query with property("xyz").isNul

      Situation: When I restrict one of my audit queries with »query.add(AuditEntity.property("parent").isNull())« the SQL generated at execution time says somthing like »parent_id = ?« instead of »parent_id is null«. Please note that the property »parent« here is a foreign key to another audited entity.



      I tried to replace the equality-operator in case of a null-value with the is-operator in the Java classes »NullAuditExpression«, method »addToQuery« and »AbstractIdMapper«, methods »addIdEqualsToQuery« / »addNamedIdEqualsToQuery«.

      The point is that altough it now reads now

      parameters.addWhereWithParam(propertyName, " is ", null);
      


      and

      if (paramData.getValue() != null) {
       parametersToUse.addWhereWithNamedParam(paramData.getProperty(prefix), equals ? "=" : "<>", paramData.getQueryParameterName());
       } else {
       parametersToUse.addWhereWithNamedParam(paramData.getProperty(prefix), equals ? " is " : " is not ", paramData.getQueryParameterName());
       }
      



      Hibernate still generates a condition with the equality-operator in case of a null-value.