@@ -1037,12 +1037,32 @@ private String addDaoConstructor(@Nullable ExecutableElement method) {
1037
1037
* is for repositories
1038
1038
*/
1039
1039
private String setupQuarkusDaoConstructor (@ Nullable ExecutableElement getter , @ Nullable TypeElement element ) {
1040
- if ( context .usesQuarkusOrm ()
1041
- || (context .usesQuarkusPanache2 ()
1042
- && element != null
1043
- && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1044
- || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )))
1040
+ boolean favorBlocking = context .usesQuarkusOrm ()
1041
+ || (context .usesQuarkusPanache2 ()
1042
+ && element != null
1043
+ && (implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1044
+ || implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )));
1045
+ if ( context .usesQuarkusPanache2 ()
1046
+ && element != null
1047
+ && !implementsInterface (element , PANACHE2_MANAGED_BLOCKING_REPOSITORY_BASE )
1048
+ && !implementsInterface (element , PANACHE2_STATELESS_BLOCKING_REPOSITORY_BASE )
1049
+ && !implementsInterface (element , PANACHE2_MANAGED_REACTIVE_REPOSITORY_BASE )
1050
+ && !implementsInterface (element , PANACHE2_STATELESS_REACTIVE_REPOSITORY_BASE )
1051
+ // FIXME: add other default for JD repos?
1045
1052
) {
1053
+ // look for any annotated method, see if they return a Uni
1054
+ final List <ExecutableElement > methodsOfClass =
1055
+ methodsIn ( context .getAllMembers ( element ) );
1056
+ for ( ExecutableElement method : methodsOfClass ) {
1057
+ // trust the first method, no need to look for them all
1058
+ if ( containsAnnotation ( method , HQL , SQL , JD_QUERY , FIND , JD_FIND ) ) {
1059
+ favorBlocking = !isUni ( method .getReturnType () );
1060
+ break ;
1061
+ }
1062
+ }
1063
+ }
1064
+ // FIXME: probably go in this branch if we have a getter too?
1065
+ if ( favorBlocking ) {
1046
1066
String name ;
1047
1067
String sessionType ;
1048
1068
if ( getter != null ) {
@@ -1598,6 +1618,15 @@ private static TypeMirror ununi(TypeMirror returnType) {
1598
1618
return returnType ;
1599
1619
}
1600
1620
1621
+ private static boolean isUni (TypeMirror returnType ){
1622
+ if ( returnType .getKind () == TypeKind .DECLARED ) {
1623
+ final DeclaredType declaredType = (DeclaredType ) returnType ;
1624
+ final TypeElement typeElement = (TypeElement ) declaredType .asElement ();
1625
+ return typeElement .getQualifiedName ().contentEquals ( Constants .UNI );
1626
+ }
1627
+ return false ;
1628
+ }
1629
+
1601
1630
private static boolean isLegalRawResultType (String containerTypeName ) {
1602
1631
return LEGAL_RAW_RESULT_TYPES .contains ( containerTypeName );
1603
1632
}
0 commit comments