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