-
Notifications
You must be signed in to change notification settings - Fork 378
Closed as not planned
Closed as not planned
Copy link
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix
Description
Hello,
I face an error when trying to bind parameters through bind() function. Note sure if i misuse the API or it is a bug from spring's side.
Code:
override suspend fun save(input: DocumentFileEntity): DocumentFileEntity {
check(input.id == 0L || input.document.id == 0L) {
"All ids should be zero, they are auto-increased by db."
}
val result = template.databaseClient.sql {
//language=MySQL
""" INSERT INTO keb.document values (text_json =:textJson);
INSERT INTO keb.document_file values (document_id=LAST_INSERT_ID() ,file_address =:fileAddress)
""".trimIndent()
}
.bind<String>("textJson", Json.encodeToString(input.document.text))
.bind<String>("fileAddress", input.fileAddress.value)
return mapToDocumentFile(result)!!
}Stacktrace:
2023-07-22T20:02:29.397+03:00 INFO 27800 --- [Test worker] keb.server.DocumentFileRouterTest : Starting DocumentFileRouterTest using Java 17.0.7 with PID 27800 (started by geolab in /home/geolab/workspaces/personal/keb/keb-server)
2023-07-22T20:02:29.398+03:00 DEBUG 27800 --- [Test worker] keb.server.DocumentFileRouterTest : Running with Spring Boot v3.0.4, Spring v6.0.6
2023-07-22T20:02:29.399+03:00 INFO 27800 --- [Test worker] keb.server.DocumentFileRouterTest : No active profile set, falling back to 1 default profile: "default"
2023-07-22T20:02:30.448+03:00 INFO 27800 --- [Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
2023-07-22T20:02:30.483+03:00 INFO 27800 --- [Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 30 ms. Found 0 R2DBC repository interfaces.
2023-07-22T20:02:32.026+03:00 INFO 27800 --- [Test worker] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 42737
2023-07-22T20:02:32.038+03:00 INFO 27800 --- [Test worker] keb.server.DocumentFileRouterTest : Started DocumentFileRouterTest in 2.938 seconds (process running for 4.35)
2023-07-22T20:02:32.742+03:00 INFO 27800 --- [reactor-http-epoll-4 @coroutine#2] keb.server.routers.DocumentFileHandler : request: /api/documentFile/create
2023-07-22T20:02:33.109+03:00 INFO 27800 --- [reactor-tcp-epoll-2 @coroutine#2] keb.server.routers.DocumentFileHandler : java.lang.IllegalArgumentException: Cannot encode value of type 'class io.r2dbc.spi.Parameters$InParameter'
at dev.miku.r2dbc.mysql.codec.DefaultCodecs.encode(DefaultCodecs.java:178)
at dev.miku.r2dbc.mysql.ParametrizedStatementSupport.bind(ParametrizedStatementSupport.java:72)
at dev.miku.r2dbc.mysql.ParametrizedStatementSupport.bind(ParametrizedStatementSupport.java:39)
at org.springframework.r2dbc.core.DefaultDatabaseClient$StatementWrapper.bind(DefaultDatabaseClient.java:556)
at org.springframework.r2dbc.core.binding.IndexedBindMarkers$IndexedBindMarker.bind(IndexedBindMarkers.java:86)
at org.springframework.r2dbc.core.NamedParameterUtils$ExpandedQuery.bind(NamedParameterUtils.java:541)
at org.springframework.r2dbc.core.NamedParameterUtils$ExpandedQuery.bindTo(NamedParameterUtils.java:590)
at org.springframework.r2dbc.core.DefaultDatabaseClient$DefaultGenericExecuteSpec.lambda$getResultFunction$5(DefaultDatabaseClient.java:378)
I can provide the full stacktrace if needed.
It seems to be quite similar to #1392.
springboot=3.0.4
r2dbcMysqlDriver=0.8.2.RELEASE
mysql-connector-java=8.0.28
Sidenote
I think it is related to 3.0.x spring version because in an older project of mine (spring 2.7.x version) bind function works. If needed i can double-check if it works in 2.7.x
Metadata
Metadata
Assignees
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix