HHH-11435 - Alias available in WITH clause although not defined yet and generates invalid SQL

- Add unit test
This commit is contained in:
Christian Beikov 2017-02-01 10:29:46 +01:00 committed by Vlad Mihalcea
parent 81c25d24f4
commit 00dfc83aeb
1 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,8 @@
package org.hibernate.test.hql; package org.hibernate.test.hql;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -68,6 +70,20 @@ public class JoinOnClauseTest extends BaseEntityManagerFunctionalTestCase {
} ); } );
} }
@Test
@TestForIssue(jiraKey = "HHH-11435")
@FailureExpected( jiraKey = "HHH-11435" )
public void testOnClauseUsesNonDrivingTableAlias() {
doInJPA( this::entityManagerFactory, entityManager -> {
try {
entityManager.createQuery("SELECT b1 FROM Book b1 JOIN Book b2 ON b1.author = author2 LEFT JOIN b2.author author2");
fail("Referring to a join alias in the on clause that is joined later should be invalid!");
} catch (IllegalArgumentException ex) {
// TODO: Assert it fails due to the alias not being defined
}
} );
}
@Entity(name = "Item") @Entity(name = "Item")
@Inheritance(strategy = InheritanceType.JOINED) @Inheritance(strategy = InheritanceType.JOINED)
public static class Item { public static class Item {