File tree 2 files changed +37
-2
lines changed
tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation
2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -2120,6 +2120,7 @@ private void addQueryMethod(
2120
2120
method .getSimpleName ().toString (),
2121
2121
processedQuery ,
2122
2122
returnType == null ? null : returnType .toString (),
2123
+ returnType == null ? null : returnTypeClass ( returnType ),
2123
2124
containerTypeName ,
2124
2125
paramNames ,
2125
2126
paramTypes ,
@@ -2137,6 +2138,36 @@ private void addQueryMethod(
2137
2138
}
2138
2139
}
2139
2140
2141
+ private static String returnTypeClass (TypeMirror returnType ) {
2142
+ switch (returnType .getKind ()) {
2143
+ case DECLARED :
2144
+ DeclaredType declaredType = (DeclaredType ) returnType ;
2145
+ final TypeElement typeElement = (TypeElement ) declaredType .asElement ();
2146
+ return typeElement .getQualifiedName ().toString ();
2147
+ case INT :
2148
+ return "int" ;
2149
+ case LONG :
2150
+ return "long" ;
2151
+ case SHORT :
2152
+ return "short" ;
2153
+ case BYTE :
2154
+ return "byte" ;
2155
+ case BOOLEAN :
2156
+ return "boolean" ;
2157
+ case FLOAT :
2158
+ return "float" ;
2159
+ case DOUBLE :
2160
+ return "double" ;
2161
+ case CHAR :
2162
+ return "char" ;
2163
+ case ARRAY :
2164
+ final ArrayType arrayType = (ArrayType ) returnType ;
2165
+ return returnTypeClass ( arrayType .getComponentType () ) + "[]" ;
2166
+ default :
2167
+ return returnType .toString ();
2168
+ }
2169
+ }
2170
+
2140
2171
private @ Nullable String implicitEntityName (@ Nullable DeclaredType resultType ) {
2141
2172
if ( resultType != null && hasAnnotation (resultType .asElement (), ENTITY ) ) {
2142
2173
final AnnotationMirror annotation =
Original file line number Diff line number Diff line change 23
23
*/
24
24
public class QueryMethod extends AbstractQueryMethod {
25
25
private final String queryString ;
26
+ private final @ Nullable String returnTypeClass ;
26
27
private final @ Nullable String containerType ;
27
28
private final boolean isUpdate ;
28
29
private final boolean isNative ;
@@ -35,6 +36,8 @@ public class QueryMethod extends AbstractQueryMethod {
35
36
@ Nullable
36
37
String returnTypeName ,
37
38
@ Nullable
39
+ String returnTypeClass ,
40
+ @ Nullable
38
41
String containerType ,
39
42
List <String > paramNames ,
40
43
List <String > paramTypes ,
@@ -54,6 +57,7 @@ public class QueryMethod extends AbstractQueryMethod {
54
57
addNonnullAnnotation ,
55
58
dataRepository );
56
59
this .queryString = queryString ;
60
+ this .returnTypeClass = returnTypeClass ;
57
61
this .containerType = containerType ;
58
62
this .isUpdate = isUpdate ;
59
63
this .isNative = isNative ;
@@ -117,10 +121,10 @@ void createQuery(StringBuilder declaration) {
117
121
.append (createQueryMethod ())
118
122
.append ("(" )
119
123
.append (getConstantName ());
120
- if ( returnTypeName != null && !isUpdate ) {
124
+ if ( returnTypeClass != null && !isUpdate ) {
121
125
declaration
122
126
.append (", " )
123
- .append (annotationMetaEntity .importType (returnTypeName ))
127
+ .append (annotationMetaEntity .importType (returnTypeClass ))
124
128
.append (".class" );
125
129
}
126
130
declaration .append (")\n " );
You can’t perform that action at this time.
0 commit comments