@@ -1052,12 +1052,32 @@ private String addDaoConstructor(@Nullable ExecutableElement method) {
1052
1052
* is for repositories
1053
1053
*/
1054
1054
private String setupQuarkusDaoConstructor (@ Nullable ExecutableElement getter , @ Nullable TypeElement element ) {
1055
- if ( context .usesQuarkusOrm ()
1056
- || (context .usesQuarkusPanache2 ()
1057
- && element != null
1058
- && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1059
- || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )))
1055
+ boolean favorBlocking = context .usesQuarkusOrm ()
1056
+ || (context .usesQuarkusPanache2 ()
1057
+ && element != null
1058
+ && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1059
+ || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )));
1060
+ if ( context .usesQuarkusPanache2 ()
1061
+ && element != null
1062
+ && !implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1063
+ && !implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )
1064
+ && !implementsInterface (element , PANACHE2_MANAGED_REACTIVE_REPOSITORY_BASE )
1065
+ && !implementsInterface (element , PANACHE2_STATELESS_REACTIVE_REPOSITORY_BASE )
1066
+ // FIXME: add other default for JD repos?
1060
1067
) {
1068
+ // look for any annotated method, see if they return a Uni
1069
+ final List <ExecutableElement > methodsOfClass =
1070
+ methodsIn ( context .getAllMembers ( element ) );
1071
+ for ( ExecutableElement method : methodsOfClass ) {
1072
+ // trust the first method, no need to look for them all
1073
+ if ( containsAnnotation ( method , HQL , SQL , JD_QUERY , FIND , JD_FIND ) ) {
1074
+ favorBlocking = !isUni ( method .getReturnType () );
1075
+ break ;
1076
+ }
1077
+ }
1078
+ }
1079
+ // FIXME: probably go in this branch if we have a getter too?
1080
+ if ( favorBlocking ) {
1061
1081
String name ;
1062
1082
String sessionType ;
1063
1083
if ( getter != null ) {
@@ -1627,6 +1647,15 @@ private static TypeMirror ununi(TypeMirror returnType) {
1627
1647
return returnType ;
1628
1648
}
1629
1649
1650
+ private static boolean isUni (TypeMirror returnType ){
1651
+ if ( returnType .getKind () == TypeKind .DECLARED ) {
1652
+ final DeclaredType declaredType = (DeclaredType ) returnType ;
1653
+ final TypeElement typeElement = (TypeElement ) declaredType .asElement ();
1654
+ return typeElement .getQualifiedName ().contentEquals ( Constants .UNI );
1655
+ }
1656
+ return false ;
1657
+ }
1658
+
1630
1659
private static boolean isLegalRawResultType (String containerTypeName ) {
1631
1660
return LEGAL_RAW_RESULT_TYPES .contains ( containerTypeName );
1632
1661
}
0 commit comments