interface UserDao : CoroutineCrudRepository<User, Long> {
@Query("SELECT * FROM user WHERE username = :$0")
suspend fun findOneByUsername(username: String): User?
}
When calling the above code, an error will be reported, and the result cannot be obtained correctly. The error is as follows
org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declared too little query method parameters!
at org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:238) ~[spring-data-commons-2.3.0.M4.jar:2.3.0.M4]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
According to my understanding, the reason for the error is that after the suspend function is compiled, a coroutine parameter is injected into the method. When springboot processes the parameter, it will try to process this parameter, then causes an error.
The version of springboot I use is 2.3.0.M3
Comment From: wilkinsona
Thanks for the report. Spring Boot isn't really involved at this point with the query being handled by Spring Data. They use JIRA for issue tracking. Can you please open a Spring Data Commons issue and comment here with a link to it?
Comment From: RhysXia
Open a issue here