|
12 | 12 | import org.hibernate.ObjectNotFoundException;
|
13 | 13 |
|
14 | 14 | import org.hibernate.testing.orm.junit.DomainModel;
|
| 15 | +import org.hibernate.testing.orm.junit.Jira; |
15 | 16 | import org.hibernate.testing.orm.junit.SessionFactory;
|
16 | 17 | import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
17 | 18 | import org.junit.jupiter.api.AfterEach;
|
@@ -55,11 +56,28 @@ void testSelectionQuery(SessionFactoryScope scope) {
|
55 | 56 | scope.inTransaction( (session) -> {
|
56 | 57 | // should not return #1
|
57 | 58 | assertThat( session.createQuery( "from JoinedRoot" ).list() ).hasSize( 2 );
|
| 59 | + assertThat( session.createQuery( "from JoinedRoot where id = 1" ).list() ).isEmpty(); |
58 | 60 | } );
|
59 | 61 |
|
60 | 62 | scope.inTransaction( (session) -> {
|
61 | 63 | // should not return #1
|
62 |
| - assertThat( session.createQuery( "from JoinedSub" ).list() ).hasSize( 2 ); |
| 64 | + assertThat( session.createQuery( "from JoinedSub where id = 1" ).list() ).isEmpty(); |
| 65 | + } ); |
| 66 | + } |
| 67 | + |
| 68 | + @Test |
| 69 | + @Jira( "https://hibernate.atlassian.net/browse/HHH-17615" ) |
| 70 | + void testCountQuery(SessionFactoryScope scope) { |
| 71 | + scope.inTransaction( (session) -> { |
| 72 | + // should not return #1 |
| 73 | + assertThat( session.createQuery( "select count(*) from JoinedRoot" ).uniqueResult() ).isEqualTo( 2L ); |
| 74 | + assertThat( session.createQuery( "select count(*) from JoinedRoot where id = 1" ).uniqueResult() ).isEqualTo( 0L ); |
| 75 | + } ); |
| 76 | + |
| 77 | + scope.inTransaction( (session) -> { |
| 78 | + // should not return #1 |
| 79 | + assertThat( session.createQuery( "select count(*) from JoinedSub" ).uniqueResult() ).isEqualTo( 2L ); |
| 80 | + assertThat( session.createQuery( "select count(*) from JoinedSub where id = 1" ).uniqueResult() ).isEqualTo( 0L ); |
63 | 81 | } );
|
64 | 82 | }
|
65 | 83 |
|
|
0 commit comments