HHH-17166 fix broken logic for inferring that @HQL method is a mutation

This commit is contained in:
Gavin King 2023-09-05 16:47:04 +02:00
parent 412217d011
commit fad11299f3
1 changed files with 9 additions and 4 deletions

View File

@ -953,10 +953,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
containerType == null ? null : containerType.getQualifiedName().toString(), containerType == null ? null : containerType.getQualifiedName().toString(),
paramNames, paramNames,
paramTypes, paramTypes,
// update/delete/insert query methods must return int or void isInsertUpdateDelete( hql ),
returnType != null
&& returnType.getKind() != TypeKind.DECLARED
&& returnType.getKind() != TypeKind.ARRAY,
isNative, isNative,
dao, dao,
sessionType[0], sessionType[0],
@ -976,6 +973,14 @@ public class AnnotationMetaEntity extends AnnotationMeta {
} }
} }
private static boolean isInsertUpdateDelete(String hql) {
final String trimmed = hql.trim();
final String keyword = trimmed.length() > 6 ? trimmed.substring(0, 6) : "";
return keyword.equalsIgnoreCase("update")
|| keyword.equalsIgnoreCase("delete")
|| keyword.equalsIgnoreCase("insert");
}
private void validateHql( private void validateHql(
ExecutableElement method, ExecutableElement method,
@Nullable TypeMirror returnType, @Nullable TypeMirror returnType,