@@ -606,6 +606,70 @@ public void testSingleResultOrNullNonUniqueException(VertxTestContext context) {
606
606
);
607
607
}
608
608
609
+ @ Test
610
+ public void testSelectionQueryGetResultCountWithStage (VertxTestContext context ) {
611
+ Author author1 = new Author ( "Iain M. Banks" );
612
+ Author author2 = new Author ( "Neal Stephenson" );
613
+ test ( context , getSessionFactory ()
614
+ .withTransaction ( s -> s .persist ( author1 , author2 ) )
615
+ .thenCompose ( v -> getSessionFactory ().withSession ( s -> s
616
+ .createSelectionQuery ( "from Author" , Author .class )
617
+ .getResultCount () ) )
618
+ .thenAccept ( count -> assertEquals ( 2L , count ) )
619
+ );
620
+ }
621
+
622
+ @ Test
623
+ public void testQueryGetResultCountWithStage (VertxTestContext context ) {
624
+ Author author1 = new Author ( "Iain M. Banks" );
625
+ Author author2 = new Author ( "Neal Stephenson" );
626
+ test ( context , getSessionFactory ()
627
+ .withTransaction ( s -> s .persist ( author1 , author2 ) )
628
+ .thenCompose ( v -> getSessionFactory ().withSession ( s -> s
629
+ .createQuery ( "from Author" , Author .class )
630
+ .getResultCount () ) )
631
+ .thenAccept ( count -> assertEquals ( 2L , count ) )
632
+ .thenCompose ( v -> getSessionFactory ().withSession ( s -> s
633
+ .createQuery ( "from Author" , Author .class )
634
+ .setMaxResults ( 1 )
635
+ .setFirstResult ( 1 )
636
+ .getResultCount () ) )
637
+ .thenAccept ( count -> assertEquals ( 2L , count ) )
638
+ );
639
+ }
640
+
641
+ @ Test
642
+ public void testSelectionQueryGetResultCountWithMutiny (VertxTestContext context ) {
643
+ Author author1 = new Author ( "Iain M. Banks" );
644
+ Author author2 = new Author ( "Neal Stephenson" );
645
+ test ( context , getSessionFactory ()
646
+ .withTransaction ( s -> s .persist ( author1 , author2 ) )
647
+ .thenCompose ( v -> getSessionFactory ().withSession ( s -> s
648
+ .createSelectionQuery ( "from Author" , Author .class )
649
+ .getResultCount () ) )
650
+ .thenAccept ( count -> assertEquals ( 2L , count ) )
651
+ );
652
+ }
653
+
654
+ @ Test
655
+ public void testQueryGetResultCountWithMutiny (VertxTestContext context ) {
656
+ Author author1 = new Author ( "Iain M. Banks" );
657
+ Author author2 = new Author ( "Neal Stephenson" );
658
+ test ( context , getMutinySessionFactory ()
659
+ .withTransaction ( s -> s .persistAll ( author1 , author2 ) )
660
+ .chain ( () -> getMutinySessionFactory ().withSession ( s -> s
661
+ .createQuery ( "from Author" , Author .class )
662
+ .getResultCount () ) )
663
+ .invoke ( count -> assertEquals ( 2L , count ) )
664
+ .chain ( () -> getMutinySessionFactory ().withSession ( s -> s
665
+ .createQuery ( "from Author" , Author .class )
666
+ .setMaxResults ( 1 )
667
+ .setFirstResult ( 1 )
668
+ .getResultCount () ) )
669
+ .invoke ( count -> assertEquals ( 2L , count ) )
670
+ );
671
+ }
672
+
609
673
@ NamedNativeQuery (
610
674
name = SQL_NAMED_QUERY ,
611
675
resultClass = Object [].class ,
0 commit comments