HHH-14279 Fix join ordering issue that happens for entity key joins when using a WITH/ON clause

This commit is contained in:
Christian Beikov 2020-10-26 19:29:38 +01:00
parent 4ffb768a7a
commit b24a3cbf2d
2 changed files with 8 additions and 0 deletions

View File

@ -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() {

View File

@ -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();