fix handling of @By("id(this)")

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-03-27 23:12:43 +01:00 committed by Christian Beikov
parent b2ec831e81
commit 49d440e653
2 changed files with 7 additions and 4 deletions

View File

@ -23,6 +23,9 @@ public interface SuperRepo<T,K> {
@Find
Optional<T> findById(@By("#id") K id);
@Find
Optional<T> findById2(@By("id(this)") K id);
@Find
Stream<T> findAll();

View File

@ -1978,9 +1978,9 @@ public class AnnotationMetaEntity extends AnnotationMeta {
return null;
}
private static boolean isIdRef(String nextToken) {
return "#id".equals(nextToken) // for Jakarta Data M4 release
|| "id(this)".equals(nextToken); // post M4
private static boolean isIdRef(String token) {
return "#id".equals(token) // for Jakarta Data M4 release
|| "id(this)".equalsIgnoreCase(token); // post M4
}
private @Nullable Element memberMatchingPath(
@ -2593,7 +2593,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
.orElse("id");
return method.getParameters().stream()
.map(AnnotationMetaEntity::parameterName)
.map(name -> "#id".equals(name) ? idName : name)
.map(name -> isIdRef(name) ? idName : name)
.collect(toList());
}