diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Bookshop.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Bookshop.java index 609946f49c..3517274543 100644 --- a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Bookshop.java +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Bookshop.java @@ -5,6 +5,8 @@ import jakarta.data.repository.Find; import jakarta.data.repository.Query; import jakarta.data.repository.Repository; import jakarta.transaction.Transactional; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; @@ -15,10 +17,10 @@ public interface Bookshop extends CrudRepository { List byPublisher(String publisher_name); @Query("select isbn where title like ?1 order by isbn") - String[] ssns(String title); + String[] ssns(@NotBlank String title); @Query("select count(this) where title like ?1 order by isbn") - long count1(String title); + long count1(@NotNull String title); @Query("select count(this) where this.title like ?1 order by this.isbn") long count2(String title); diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java index 194b7d22ea..0d92ef1f45 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java @@ -2562,6 +2562,16 @@ public class AnnotationMetaEntity extends AnnotationMeta { } } + private static String stripTypeAnnotations(String argType) { + while ( argType.startsWith("@") ) { + int index = argType.indexOf(' '); + if (index>0) { + argType = argType.substring(index+1); + } + } + return argType; + } + private void checkNamedParameter( SqmParameter param, List paramNames, List paramTypes, ExecutableElement method, AnnotationMirror mirror, AnnotationValue value, String queryParamType) { @@ -2584,7 +2594,8 @@ public class AnnotationMetaEntity extends AnnotationMeta { } } - private static boolean isLegalAssignment(SqmParameter param, String argType, String queryParamType) { + private static boolean isLegalAssignment(SqmParameter param, String argumentType, String queryParamType) { + final String argType = stripTypeAnnotations(argumentType); return param.allowMultiValuedBinding() ? isLegalAssignment(argType, LIST + '<' + queryParamType + '>') : isLegalAssignment(argType, queryParamType); @@ -2636,7 +2647,12 @@ public class AnnotationMetaEntity extends AnnotationMeta { private String typeAsString(TypeMirror type) { String result = type.toString(); for ( AnnotationMirror annotation : type.getAnnotationMirrors() ) { - result = result.replace(annotation.toString(), ""); + final String annotationString = annotation.toString(); + result = result + // if it has a space after it, we need to remove that too + .replace(annotationString + ' ', "") + // just in case it did not have a space after it + .replace(annotationString, ""); } for ( AnnotationMirror annotation : type.getAnnotationMirrors() ) { result = annotation.toString() + ' ' + result;