From 4a53df0dd340543c959feb398377dba8734c744b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 25 Jun 2018 15:17:25 +0200 Subject: [PATCH] HHH-12594 Do not share AliasResolutionContextImpl between EntityLoadQueryDetails instances Sharing it results in some tables being aliased twice for the same query space, but with different aliases, resulting in exceptions. Ideally we should try to generate the aliases once, and then share the AliasResolutionContextImpl between EntityLoadQueryDetails instances, but I'm really not comfortable enough with this code to make that kind of changes. --- .../plan/exec/internal/EntityLoadQueryDetails.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityLoadQueryDetails.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityLoadQueryDetails.java index 1abf779335..08a0dd15ae 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityLoadQueryDetails.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityLoadQueryDetails.java @@ -87,17 +87,14 @@ public class EntityLoadQueryDetails extends AbstractLoadQueryDetails { protected EntityLoadQueryDetails( EntityLoadQueryDetails initialEntityLoadQueryDetails, QueryBuildingParameters buildingParameters) { - super( + this( initialEntityLoadQueryDetails.getLoadPlan(), - (AliasResolutionContextImpl) initialEntityLoadQueryDetails.getAliasResolutionContext(), - buildingParameters, initialEntityLoadQueryDetails.getKeyColumnNames(), - initialEntityLoadQueryDetails.getRootReturn(), + new AliasResolutionContextImpl( initialEntityLoadQueryDetails.getSessionFactory() ), + (EntityReturn) initialEntityLoadQueryDetails.getRootReturn(), + buildingParameters, initialEntityLoadQueryDetails.getSessionFactory() ); - this.entityReferenceAliases = initialEntityLoadQueryDetails.entityReferenceAliases; - this.readerCollector = initialEntityLoadQueryDetails.readerCollector; - generate(); } private EntityReturn getRootEntityReturn() {