Skip to content

Commit 88c9758

Browse files
committed
HHH-19116 Add test for issue
1 parent afe8e72 commit 88c9758

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/query/LeftJoinNullnessPredicateQueryTest.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010

1111
import org.hibernate.testing.orm.junit.DomainModel;
12+
import org.hibernate.testing.orm.junit.Jira;
1213
import org.hibernate.testing.orm.junit.SessionFactory;
1314
import org.hibernate.testing.orm.junit.SessionFactoryScope;
1415
import org.junit.jupiter.api.AfterAll;
@@ -29,7 +30,11 @@
2930
@DomainModel( annotatedClasses = {
3031
LeftJoinNullnessPredicateQueryTest.Author.class,
3132
LeftJoinNullnessPredicateQueryTest.Book.class
32-
} )
33+
})
34+
@Jira( "https://hibernate.atlassian.net/browse/HHH-16505" )
35+
@Jira( "https://hibernate.atlassian.net/browse/HHH-17379" )
36+
@Jira( "https://hibernate.atlassian.net/browse/HHH-17397" )
37+
@Jira( "https://hibernate.atlassian.net/browse/HHH-19116" )
3338
public class LeftJoinNullnessPredicateQueryTest {
3439
@BeforeAll
3540
public void setUp(SessionFactoryScope scope) {
@@ -80,6 +85,19 @@ public void testIsNotNull(SessionFactoryScope scope) {
8085
} );
8186
}
8287

88+
@Test
89+
public void testIsNullImplicit(SessionFactoryScope scope) {
90+
scope.inTransaction( session -> {
91+
final List<Book> resultList = session.createQuery(
92+
"select book from Book book " +
93+
"where book.author is null",
94+
Book.class
95+
).getResultList();
96+
assertThat( resultList ).hasSize( 1 );
97+
assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" );
98+
} );
99+
}
100+
83101
@Test
84102
public void testDereferenceIsNull(SessionFactoryScope scope) {
85103
scope.inTransaction( session -> {
@@ -108,6 +126,19 @@ public void testDereferenceIsNotNull(SessionFactoryScope scope) {
108126
} );
109127
}
110128

129+
@Test
130+
public void testFkImplicitIsNull(SessionFactoryScope scope) {
131+
scope.inTransaction( session -> {
132+
final List<Book> resultList = session.createQuery(
133+
"select book from Book book " +
134+
"where fk(book.author) is null",
135+
Book.class
136+
).getResultList();
137+
assertThat( resultList ).hasSize( 1 );
138+
assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" );
139+
} );
140+
}
141+
111142
@Test
112143
public void testIsNotNullWithCondition(SessionFactoryScope scope) {
113144
scope.inTransaction( session -> {

0 commit comments

Comments
 (0)