Skip to content
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

Can't use interface access for database access when using Kotlin's suspend [DATACMNS-1687] #2110

Closed
spring-projects-issues opened this issue Mar 18, 2020 · 4 comments
Assignees
Labels
in: repository status: invalid

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Mar 18, 2020

RhysXia opened DATACMNS-1687 and commented

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!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


Affects: 2.3 M4 (Neumann)

Reference URL: spring-projects/spring-boot#20552

Issue Links:

  • DATACMNS-1689 RepositoryMetadata.getReturnedDomainClass(...) returns Object for suspended methods
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 18, 2020

Mark Paluch commented

Can you provide a reproducer? Which Spring Data module are you using?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 18, 2020

RhysXia commented

you can find a reproducer [here|https://github.com/RhysXia/issue-spring-data-r2dbc].

I provide two api, api "/users" can request to all users. api  "/users/{username}" can request the user with the specified username. The above problem will occur when requesting this api.
 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 19, 2020

Mark Paluch commented

Thanks a lot. That issue is created by Spring Data R2DBC. I filed spring-projects/spring-data-r2dbc#321 to track that issue

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 19, 2020

Mark Paluch commented

While investigating the fix, we found another issue, see DATACMNS-1689

@spring-projects-issues spring-projects-issues added status: invalid in: repository labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository status: invalid
Projects
None yet
Development

No branches or pull requests

2 participants