HHH-17860 report bad return type for @Delete

This commit is contained in:
Gavin King 2024-03-22 18:28:26 +01:00
parent c3e210e923
commit 8b021ac01f
1 changed files with 19 additions and 4 deletions

View File

@ -1082,9 +1082,25 @@ public class AnnotationMetaEntity extends AnnotationMeta {
addFinderMethod( method, returnType, containerType );
}
else if ( hasAnnotation( method, JD_DELETE ) ) {
addDeleteMethod( method, returnType );
}
}
private void addDeleteMethod(ExecutableElement method, @Nullable TypeMirror returnType) {
if ( returnType != null ) {
final TypeKind kind = returnType.getKind();
if ( kind != TypeKind.VOID
&& kind != TypeKind.INT
&& kind != TypeKind.LONG ) {
context.message(method,
"must be 'void' or return 'int' or 'long'",
Diagnostic.Kind.ERROR);
}
else {
createCriteriaDelete(method, returnType);
}
}
}
private void addLifecycleMethod(ExecutableElement method) {
final TypeMirror returnType = method.getReturnType();
@ -1351,8 +1367,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
);
}
private void createCriteriaDelete(
ExecutableElement method, @Nullable TypeMirror returnType) {
private void createCriteriaDelete(ExecutableElement method, TypeMirror returnType) {
final TypeElement entity = primaryEntity;
if ( entity == null) {
context.message( method, "repository does not have a well-defined primary entity type",
@ -1379,7 +1394,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
this,
methodName,
entity.getQualifiedName().toString(),
returnType==null ? "void" : returnType.toString(),
returnType.toString(),
paramNames,
paramTypes,
parameterNullability(method, entity),