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
parent 2955e0b91d
commit e1bcd01321
2 changed files with 7 additions and 4 deletions

View File

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

View File

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