@@ -1044,12 +1044,32 @@ private String addDaoConstructor(@Nullable ExecutableElement method) {
10441044 * is for repositories
10451045 */
10461046 private String setupQuarkusDaoConstructor (@ Nullable ExecutableElement getter , @ Nullable TypeElement element ) {
1047- if ( context .usesQuarkusOrm ()
1048- || (context .usesQuarkusPanache2 ()
1049- && element != null
1050- && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1051- || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )))
1047+ boolean favorBlocking = context .usesQuarkusOrm ()
1048+ || (context .usesQuarkusPanache2 ()
1049+ && element != null
1050+ && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1051+ || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )));
1052+ if ( context .usesQuarkusPanache2 ()
1053+ && element != null
1054+ && !implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1055+ && !implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )
1056+ && !implementsInterface (element , PANACHE2_MANAGED_REACTIVE_REPOSITORY_BASE )
1057+ && !implementsInterface (element , PANACHE2_STATELESS_REACTIVE_REPOSITORY_BASE )
1058+ // FIXME: add other default for JD repos?
10521059 ) {
1060+ // look for any annotated method, see if they return a Uni
1061+ final List <ExecutableElement > methodsOfClass =
1062+ methodsIn ( context .getAllMembers ( element ) );
1063+ for ( ExecutableElement method : methodsOfClass ) {
1064+ // trust the first method, no need to look for them all
1065+ if ( containsAnnotation ( method , HQL , SQL , JD_QUERY , FIND , JD_FIND ) ) {
1066+ favorBlocking = !isUni ( method .getReturnType () );
1067+ break ;
1068+ }
1069+ }
1070+ }
1071+ // FIXME: probably go in this branch if we have a getter too?
1072+ if ( favorBlocking ) {
10531073 String name ;
10541074 String sessionType ;
10551075 if ( getter != null ) {
@@ -1602,6 +1622,15 @@ private static TypeMirror ununi(TypeMirror returnType) {
16021622 return returnType ;
16031623 }
16041624
1625+ private static boolean isUni (TypeMirror returnType ){
1626+ if ( returnType .getKind () == TypeKind .DECLARED ) {
1627+ final DeclaredType declaredType = (DeclaredType ) returnType ;
1628+ final TypeElement typeElement = (TypeElement ) declaredType .asElement ();
1629+ return typeElement .getQualifiedName ().contentEquals ( Constants .UNI );
1630+ }
1631+ return false ;
1632+ }
1633+
16051634 private static boolean isLegalRawResultType (String containerTypeName ) {
16061635 return LEGAL_RAW_RESULT_TYPES .contains ( containerTypeName );
16071636 }
0 commit comments