Skip to content

Commit

Permalink
HHH-19116 Add test for issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel committed Feb 19, 2025
1 parent afe8e72 commit 88c9758
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;

import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterAll;
Expand All @@ -29,7 +30,11 @@
@DomainModel( annotatedClasses = {
LeftJoinNullnessPredicateQueryTest.Author.class,
LeftJoinNullnessPredicateQueryTest.Book.class
} )
})
@Jira( "https://hibernate.atlassian.net/browse/HHH-16505" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-17379" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-17397" )
@Jira( "https://hibernate.atlassian.net/browse/HHH-19116" )
public class LeftJoinNullnessPredicateQueryTest {
@BeforeAll
public void setUp(SessionFactoryScope scope) {
Expand Down Expand Up @@ -80,6 +85,19 @@ public void testIsNotNull(SessionFactoryScope scope) {
} );
}

@Test
public void testIsNullImplicit(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final List<Book> resultList = session.createQuery(
"select book from Book book " +
"where book.author is null",
Book.class
).getResultList();
assertThat( resultList ).hasSize( 1 );
assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" );
} );
}

@Test
public void testDereferenceIsNull(SessionFactoryScope scope) {
scope.inTransaction( session -> {
Expand Down Expand Up @@ -108,6 +126,19 @@ public void testDereferenceIsNotNull(SessionFactoryScope scope) {
} );
}

@Test
public void testFkImplicitIsNull(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final List<Book> resultList = session.createQuery(
"select book from Book book " +
"where fk(book.author) is null",
Book.class
).getResultList();
assertThat( resultList ).hasSize( 1 );
assertThat( resultList.get( 0 ).getTitle() ).isEqualTo( "Unknown Author" );
} );
}

@Test
public void testIsNotNullWithCondition(SessionFactoryScope scope) {
scope.inTransaction( session -> {
Expand Down

0 comments on commit 88c9758

Please sign in to comment.