-
Notifications
You must be signed in to change notification settings - Fork 132
MappingException when calling a modifying query method that returns kotlin.Unit #421
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
Labels
type: bug
A general bug
Milestone
Comments
ada-waffles
added a commit
to ada-waffles/spring-data-r2dbc
that referenced
this issue
Jul 30, 2020
….Unit. Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Added AbstractR2dbcQueryUnitTests to test the functionality surrounding the main change. Also added integration tests surrounding modifying query return types.
Thanks for reporting the issue. Returning |
I filed DATACMNS-1779 to provide void type detection. Looking at the pull request, we can simplify it by quite a bit. |
mp911de
added a commit
that referenced
this issue
Jul 31, 2020
…Unit. We now discard results for suspended query methods if the return type is kotlin.Unit. Related ticket: DATACMNS-1779 Original pull request: #422.
mp911de
pushed a commit
that referenced
this issue
Jul 31, 2020
Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Original pull request: #422.
mp911de
added a commit
that referenced
this issue
Jul 31, 2020
Simplify tests. Use ReflectionUtils.isVoid(…) where possible and simplify isVoid(…) flows. Original pull request: #422.
mp911de
added a commit
that referenced
this issue
Jul 31, 2020
…Unit. We now discard results for suspended query methods if the return type is kotlin.Unit. Related ticket: DATACMNS-1779 Original pull request: #422.
mp911de
pushed a commit
that referenced
this issue
Jul 31, 2020
Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Original pull request: #422.
mp911de
added a commit
that referenced
this issue
Jul 31, 2020
Simplify tests. Use ReflectionUtils.isVoid(…) where possible and simplify isVoid(…) flows. Original pull request: #422.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modifying queries can be declared as returning
Void
if the result count information is not needed, as shown here. The equivalent declaration in Kotlin would be to useUnit
. Currently, Spring Data R2DBC does not recognize theUnit
type and attempts to convert the affected row count toUnit
as if it were a projection, resulting in:An example repository method that is affected:
A workaround is to simply use the Java
Void
type:I believe I've tracked this down to
AbstractR2dbcQuery#getExecutionToWrap
and plan to attempt a PR.The text was updated successfully, but these errors were encountered: