|
7 | 7 | import java.util.List; |
8 | 8 |
|
9 | 9 | import org.hibernate.testing.orm.junit.DomainModel; |
| 10 | +import org.hibernate.testing.orm.junit.Jira; |
10 | 11 | import org.hibernate.testing.orm.junit.SessionFactory; |
11 | 12 | import org.hibernate.testing.orm.junit.SessionFactoryScope; |
12 | 13 | import org.junit.jupiter.api.AfterAll; |
|
27 | 28 | @DomainModel( annotatedClasses = { |
28 | 29 | LeftJoinNullnessPredicateQueryTest.Author.class, |
29 | 30 | LeftJoinNullnessPredicateQueryTest.Book.class |
30 | | -} ) |
| 31 | +}) |
| 32 | +@Jira( "https://hibernate.atlassian.net/browse/HHH-16505" ) |
| 33 | +@Jira( "https://hibernate.atlassian.net/browse/HHH-17379" ) |
| 34 | +@Jira( "https://hibernate.atlassian.net/browse/HHH-17397" ) |
| 35 | +@Jira( "https://hibernate.atlassian.net/browse/HHH-19116" ) |
31 | 36 | public class LeftJoinNullnessPredicateQueryTest { |
32 | 37 | @BeforeAll |
33 | 38 | public void setUp(SessionFactoryScope scope) { |
@@ -78,6 +83,19 @@ public void testIsNotNull(SessionFactoryScope scope) { |
78 | 83 | } ); |
79 | 84 | } |
80 | 85 |
|
| 86 | + @Test |
| 87 | + public void testIsNullImplicit(SessionFactoryScope scope) { |
| 88 | + scope.inTransaction( session -> { |
| 89 | + final List<Book> resultList = session.createQuery( |
| 90 | + "select book from Book book " + |
| 91 | + "where book.author is null", |
| 92 | + Book.class |
| 93 | + ).getResultList(); |
| 94 | + assertThat( resultList ).hasSize( 1 ); |
| 95 | + assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" ); |
| 96 | + } ); |
| 97 | + } |
| 98 | + |
81 | 99 | @Test |
82 | 100 | public void testDereferenceIsNull(SessionFactoryScope scope) { |
83 | 101 | scope.inTransaction( session -> { |
@@ -106,6 +124,33 @@ public void testDereferenceIsNotNull(SessionFactoryScope scope) { |
106 | 124 | } ); |
107 | 125 | } |
108 | 126 |
|
| 127 | + @Test |
| 128 | + public void testFkImplicitIsNull(SessionFactoryScope scope) { |
| 129 | + scope.inTransaction( session -> { |
| 130 | + final List<Book> resultList = session.createQuery( |
| 131 | + "select book from Book book " + |
| 132 | + "where fk(book.author) is null", |
| 133 | + Book.class |
| 134 | + ).getResultList(); |
| 135 | + assertThat( resultList ).hasSize( 1 ); |
| 136 | + assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" ); |
| 137 | + } ); |
| 138 | + } |
| 139 | + |
| 140 | + @Test |
| 141 | + public void testFkImplicitIsNullJoinOr(SessionFactoryScope scope) { |
| 142 | + scope.inTransaction( session -> { |
| 143 | + final List<Book> resultList = session.createQuery( |
| 144 | + "select book from Book book " + |
| 145 | + "left join book.author a " + |
| 146 | + "where fk(book.author) is null or a.name = 'Stephen King'", |
| 147 | + Book.class |
| 148 | + ).getResultList(); |
| 149 | + assertThat( resultList ).hasSize( 1 ); |
| 150 | + assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" ); |
| 151 | + } ); |
| 152 | + } |
| 153 | + |
109 | 154 | @Test |
110 | 155 | public void testIsNotNullWithCondition(SessionFactoryScope scope) { |
111 | 156 | scope.inTransaction( session -> { |
|
0 commit comments