|
43 | 43 | import static jakarta.persistence.FetchType.LAZY;
|
44 | 44 | import static java.util.concurrent.TimeUnit.MINUTES;
|
45 | 45 | import static org.assertj.core.api.Assertions.assertThat;
|
| 46 | +import static org.assertj.core.groups.Tuple.tuple; |
46 | 47 | import static org.hibernate.reactive.QueryTest.Author.AUTHOR_TABLE;
|
47 | 48 | import static org.hibernate.reactive.QueryTest.Author.HQL_NAMED_QUERY;
|
48 | 49 | import static org.hibernate.reactive.QueryTest.Author.SQL_NAMED_QUERY;
|
@@ -395,6 +396,42 @@ public void testNativeEntityQueryWithParam(VertxTestContext context) {
|
395 | 396 | );
|
396 | 397 | }
|
397 | 398 |
|
| 399 | + // https://github.com/hibernate/hibernate-reactive/issues/2314 |
| 400 | + @Test |
| 401 | + public void testNativeEntityQueryWithLimit(VertxTestContext context) { |
| 402 | + Author author1 = new Author( "Iain M. Banks" ); |
| 403 | + Author author2 = new Author( "Neal Stephenson" ); |
| 404 | + Book book1 = new Book( "1-85723-235-6", "Feersum Endjinn", author1 ); |
| 405 | + Book book2 = new Book( "0-380-97346-4", "Cryptonomicon", author2 ); |
| 406 | + Book book3 = new Book( "0-553-08853-X", "Snow Crash", author2 ); |
| 407 | + author1.books.add( book1 ); |
| 408 | + author2.books.add( book2 ); |
| 409 | + author2.books.add( book3 ); |
| 410 | + |
| 411 | + test( |
| 412 | + context, |
| 413 | + openSession() |
| 414 | + .thenCompose( session -> session.persist( author1, author2 ) |
| 415 | + .thenCompose( v -> session.flush() ) |
| 416 | + ) |
| 417 | + .thenCompose( v -> openSession() ) |
| 418 | + .thenCompose( session -> session.createNativeQuery( |
| 419 | + "select * from " + BOOK_TABLE + " order by isbn", |
| 420 | + Book.class |
| 421 | + ) |
| 422 | + .setMaxResults( 2 ) |
| 423 | + .getResultList() ) |
| 424 | + .thenAccept( books -> { |
| 425 | + assertThat( books ) |
| 426 | + .extracting( b -> b.id, b -> b.title, b -> b.isbn ) |
| 427 | + .containsExactly( |
| 428 | + tuple( book2.id, book2.title, book2.isbn ), |
| 429 | + tuple( book3.id, book3.title, book3.isbn ) |
| 430 | + ); |
| 431 | + } ) |
| 432 | + ); |
| 433 | + } |
| 434 | + |
398 | 435 | @Test
|
399 | 436 | public void testNativeEntityQueryWithNamedParam(VertxTestContext context) {
|
400 | 437 | Author author1 = new Author( "Iain M. Banks" );
|
|
0 commit comments