diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java index 2e03bf1130..1ff9df15fa 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java @@ -94,6 +94,9 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di void moveFromElementToEnd(FromElement element) { fromElements.remove( element ); fromElements.add( element ); + // We must move destinations which must come after the from element as well + fromElements.removeAll( element.getDestinations() ); + fromElements.addAll( element.getDestinations() ); } public void finishInit() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/MapIssueTest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/MapIssueTest.java index 6f18811863..9e4eed09f9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/MapIssueTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/MapIssueTest.java @@ -7,12 +7,16 @@ package org.hibernate.test.jpa.ql; import org.hibernate.Session; +import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.test.jpa.AbstractJPATest; import org.hibernate.test.jpa.MapContent; import org.hibernate.test.jpa.MapOwner; import org.hibernate.test.jpa.Relationship; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.TestForIssue; import org.junit.Test; +@TestForIssue(jiraKey = "HHH-14279") public class MapIssueTest extends AbstractJPATest { @Override @@ -25,6 +29,7 @@ public class MapIssueTest extends AbstractJPATest { } @Test + @RequiresDialect(value = PostgreSQL81Dialect.class, comment = "Requires support for using a correlated column in a join condition which H2 apparently does not support.") public void testWhereSubqueryMapKeyIsEntityWhereWithKey() { Session s = openSession(); s.beginTransaction();