Skip to content

Commit

Permalink
fix handling of @by("id(this)")
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin King <gavin@hibernate.org>
  • Loading branch information
gavinking committed Mar 27, 2024
1 parent 2955e0b commit e1bcd01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1978,9 +1978,9 @@ private static TypeMirror memberType(Element member) {
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(
Expand Down Expand Up @@ -2593,7 +2593,7 @@ private List<String> parameterNames(ExecutableElement method, TypeElement entity
.orElse("id");
return method.getParameters().stream()
.map(AnnotationMetaEntity::parameterName)
.map(name -> "#id".equals(name) ? idName : name)
.map(name -> isIdRef(name) ? idName : name)
.collect(toList());
}

Expand Down

0 comments on commit e1bcd01

Please sign in to comment.