diff --git a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java index 647b8f109..992c171d9 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java +++ b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java @@ -87,6 +87,12 @@ public class PartTree implements Streamable { Assert.notNull(source, "Source must not be null"); Assert.notNull(domainClass, "Domain class must not be null"); + // Kotlin name mangling, @JvmName cannot be used with interfaces + int dash = source.indexOf('-'); + if (dash > -1) { + source = source.substring(0, dash); + } + Matcher matcher = PREFIX_TEMPLATE.matcher(source); if (!matcher.find()) { diff --git a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java index 00a3acd10..4c046098d 100755 --- a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java +++ b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java @@ -27,7 +27,6 @@ import java.util.Date; import java.util.List; import org.junit.jupiter.api.Test; - import org.springframework.data.domain.Limit; import org.springframework.data.domain.Sort; import org.springframework.data.mapping.PropertyPath; @@ -657,6 +656,14 @@ class PartTreeUnitTests { assertThat(tree.getSort()).hasSize(1); } + @Test // GH-2965 + void unmangleKotlinMethodName() { + + var tree = new PartTree("findById-u1QWhUI", Order.class); + + assertThat(tree.getParts()).hasSize(1); + } + private static void assertLimiting(String methodName, Class entityType, boolean limiting, Integer maxResults) { assertLimiting(methodName, entityType, limiting, maxResults, false); }