From 2eaa5e24922258404f98ba576caa9e2c66c6d178 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Mon, 31 Oct 2016 12:29:17 -0400 Subject: [PATCH] HHH-11214 - Fix validity audit strategy auditing nested collections with null property values. (cherry picked from commit af78f17eb8ead6659f7be9149ecee3677ce60e52) --- .../hibernate/envers/strategy/ValidityAuditStrategy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java index da713fa176..05cd663248 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java @@ -267,9 +267,15 @@ public class ValidityAuditStrategy implements AuditStrategy { // Handling collection of components. if ( collectionPropertyType.getElementType( sessionFactory ) instanceof ComponentType ) { // Adding restrictions to compare data outside of primary key. + // todo: is it necessary that non-primary key attributes be compared? for ( Map.Entry dataEntry : persistentCollectionChangeData.getData().entrySet() ) { if ( !originalIdPropName.equals( dataEntry.getKey() ) ) { - qb.getRootParameters().addWhereWithParam( dataEntry.getKey(), true, "=", dataEntry.getValue() ); + if ( dataEntry.getValue() != null ) { + qb.getRootParameters().addWhereWithParam( dataEntry.getKey(), true, "=", dataEntry.getValue() ); + } + else { + qb.getRootParameters().addNullRestriction( dataEntry.getKey(), true ); + } } } }