From a7f77e2687067c2b1529d12392771e0a38ba92a1 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Wed, 24 May 2017 19:59:12 -0400 Subject: [PATCH] HHH-11770 - Fix for audited queries for OneToMany associated to an EmbeddedId property. --- .../mapper/relation/query/OneAuditEntityQueryGenerator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java index 0edf153165..86958a938c 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java @@ -8,8 +8,8 @@ package org.hibernate.envers.internal.entities.mapper.relation.query; import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration; import org.hibernate.envers.configuration.internal.GlobalConfiguration; +import org.hibernate.envers.internal.entities.mapper.id.AbstractCompositeIdMapper; import org.hibernate.envers.internal.entities.mapper.id.IdMapper; -import org.hibernate.envers.internal.entities.mapper.id.MultipleIdMapper; import org.hibernate.envers.internal.entities.mapper.relation.MiddleIdData; import org.hibernate.envers.internal.tools.query.Parameters; import org.hibernate.envers.internal.tools.query.QueryBuilder; @@ -47,7 +47,9 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen this.mappedBy = mappedBy; - if ( ( referencedIdData.getOriginalMapper() instanceof MultipleIdMapper ) && mappedByKey ) { + // HHH-11770 We use AbstractCompositeIdMapper here to handle EmbeddedIdMapper and MultipleIdMappper support + // so that OneAuditEntityQueryGenerator supports mappings to both @IdClass and @EmbeddedId components. + if ( ( referencedIdData.getOriginalMapper() instanceof AbstractCompositeIdMapper ) && mappedByKey ) { multipleIdMapperKey = true; } else {