-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repository method override not picked up #2888
Comments
The signatures do not match because the |
We could change the lookup to something like the following which worked for the given example. return Optional.ofNullable(ReflectionUtils.findMethod(type, name, parameterTypes)).or(() -> {
return stream(type.getDeclaredMethods()).filter(it -> it.getName().equals(name) && it.getParameterCount() == parameterTypes
.filter(it -> {
for(int i = 0; i<it.getParameterCount(); i++) {
Class<?> currentParameterType = it.getParameterTypes()[i];
if(currentParameterType != parameterTypes[i] && ClassUtils.isPrimitiveWrapper(currentParameterType)) {
if(!ClassUtils.isAssignable(parameterTypes[i], currentParameterType)) {
return false;
}
}
}
return true;
})
.findFirst();
}); |
can u try like this? @Repository
@JvmDefaultWithCompatibility
inteface UserRepository: CrudRepository<User, Long> {
override fun findAll(): MutableIterable<User> {
throw UnsupportedOperationException()
}
} @christophstrobl Is working progress? |
I am struggling with the same issue. I first disabled Kotlin warnings as errors and defined the parameter as nullable What I am doing regarding customization is adding a PreAuthorize annotation to it.
|
after some hours of experiment the best solution i found is to use UUID :)
and it works perfectly |
Using Spring Boot Data 3.0.6, with Kotlin.
I have a
UserRepository
extending aCrudRepository
, with a method overrideMy default method exposure is disabled.
When I call my REST endpoint on
/users/123
I get a 405 Method Not Allowed. If I enable method exposure, the default implementation fromCrudRepository
is being picked up instead of my custom declared repository method.If I declare a custom
findAll()
, this gets picked up without issues.I did some digging and it seems that in
DefaultCrudMethods.selectMostSuitableFindOneMethod(...)
it fails to find the custom interface method, it however does find the CrudRepository one. It callsReflectionUtils.findMethod(UserRepository.class, "findById", Long.class)
, and there the comparison of parameter types somehow fails.The text was updated successfully, but these errors were encountered: