@@ -1044,12 +1044,32 @@ private String addDaoConstructor(@Nullable ExecutableElement method) {
1044
1044
* is for repositories
1045
1045
*/
1046
1046
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?
1052
1059
) {
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 ) {
1053
1073
String name ;
1054
1074
String sessionType ;
1055
1075
if ( getter != null ) {
@@ -1602,6 +1622,15 @@ private static TypeMirror ununi(TypeMirror returnType) {
1602
1622
return returnType ;
1603
1623
}
1604
1624
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
+
1605
1634
private static boolean isLegalRawResultType (String containerTypeName ) {
1606
1635
return LEGAL_RAW_RESULT_TYPES .contains ( containerTypeName );
1607
1636
}
0 commit comments