fix bug where type annotations got generated onto Class literals
needed for Jakarta Data TCK Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
3370dc81bc
commit
74c026b27d
|
@ -2120,6 +2120,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
method.getSimpleName().toString(),
|
method.getSimpleName().toString(),
|
||||||
processedQuery,
|
processedQuery,
|
||||||
returnType == null ? null : returnType.toString(),
|
returnType == null ? null : returnType.toString(),
|
||||||
|
returnType == null ? null : returnTypeClass( returnType ),
|
||||||
containerTypeName,
|
containerTypeName,
|
||||||
paramNames,
|
paramNames,
|
||||||
paramTypes,
|
paramTypes,
|
||||||
|
@ -2137,6 +2138,36 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String returnTypeClass(TypeMirror returnType) {
|
||||||
|
switch (returnType.getKind()) {
|
||||||
|
case DECLARED:
|
||||||
|
DeclaredType declaredType = (DeclaredType) returnType;
|
||||||
|
final TypeElement typeElement = (TypeElement) declaredType.asElement();
|
||||||
|
return typeElement.getQualifiedName().toString();
|
||||||
|
case INT:
|
||||||
|
return "int";
|
||||||
|
case LONG:
|
||||||
|
return "long";
|
||||||
|
case SHORT:
|
||||||
|
return "short";
|
||||||
|
case BYTE:
|
||||||
|
return "byte";
|
||||||
|
case BOOLEAN:
|
||||||
|
return "boolean";
|
||||||
|
case FLOAT:
|
||||||
|
return "float";
|
||||||
|
case DOUBLE:
|
||||||
|
return "double";
|
||||||
|
case CHAR:
|
||||||
|
return "char";
|
||||||
|
case ARRAY:
|
||||||
|
final ArrayType arrayType = (ArrayType) returnType;
|
||||||
|
return returnTypeClass( arrayType.getComponentType() ) + "[]";
|
||||||
|
default:
|
||||||
|
return returnType.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private @Nullable String implicitEntityName(@Nullable DeclaredType resultType) {
|
private @Nullable String implicitEntityName(@Nullable DeclaredType resultType) {
|
||||||
if ( resultType != null && hasAnnotation(resultType.asElement(), ENTITY) ) {
|
if ( resultType != null && hasAnnotation(resultType.asElement(), ENTITY) ) {
|
||||||
final AnnotationMirror annotation =
|
final AnnotationMirror annotation =
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.hibernate.processor.util.StringUtil.getUpperUnderscoreCaseFrom
|
||||||
*/
|
*/
|
||||||
public class QueryMethod extends AbstractQueryMethod {
|
public class QueryMethod extends AbstractQueryMethod {
|
||||||
private final String queryString;
|
private final String queryString;
|
||||||
|
private final @Nullable String returnTypeClass;
|
||||||
private final @Nullable String containerType;
|
private final @Nullable String containerType;
|
||||||
private final boolean isUpdate;
|
private final boolean isUpdate;
|
||||||
private final boolean isNative;
|
private final boolean isNative;
|
||||||
|
@ -35,6 +36,8 @@ public class QueryMethod extends AbstractQueryMethod {
|
||||||
@Nullable
|
@Nullable
|
||||||
String returnTypeName,
|
String returnTypeName,
|
||||||
@Nullable
|
@Nullable
|
||||||
|
String returnTypeClass,
|
||||||
|
@Nullable
|
||||||
String containerType,
|
String containerType,
|
||||||
List<String> paramNames,
|
List<String> paramNames,
|
||||||
List<String> paramTypes,
|
List<String> paramTypes,
|
||||||
|
@ -54,6 +57,7 @@ public class QueryMethod extends AbstractQueryMethod {
|
||||||
addNonnullAnnotation,
|
addNonnullAnnotation,
|
||||||
dataRepository );
|
dataRepository );
|
||||||
this.queryString = queryString;
|
this.queryString = queryString;
|
||||||
|
this.returnTypeClass = returnTypeClass;
|
||||||
this.containerType = containerType;
|
this.containerType = containerType;
|
||||||
this.isUpdate = isUpdate;
|
this.isUpdate = isUpdate;
|
||||||
this.isNative = isNative;
|
this.isNative = isNative;
|
||||||
|
@ -117,10 +121,10 @@ public class QueryMethod extends AbstractQueryMethod {
|
||||||
.append(createQueryMethod())
|
.append(createQueryMethod())
|
||||||
.append("(")
|
.append("(")
|
||||||
.append(getConstantName());
|
.append(getConstantName());
|
||||||
if ( returnTypeName != null && !isUpdate ) {
|
if ( returnTypeClass != null && !isUpdate ) {
|
||||||
declaration
|
declaration
|
||||||
.append(", ")
|
.append(", ")
|
||||||
.append(annotationMetaEntity.importType(returnTypeName))
|
.append(annotationMetaEntity.importType(returnTypeClass))
|
||||||
.append(".class");
|
.append(".class");
|
||||||
}
|
}
|
||||||
declaration.append(")\n");
|
declaration.append(")\n");
|
||||||
|
|
Loading…
Reference in New Issue