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

Fix JdbcOperations.queryForObject/queryForList extensions #26312

Closed
m15o opened this issue Dec 23, 2020 · 0 comments
Closed

Fix JdbcOperations.queryForObject/queryForList extensions #26312

m15o opened this issue Dec 23, 2020 · 0 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Milestone

Comments

@m15o
Copy link

m15o commented Dec 23, 2020

Affects: 5.3.2

JdbcOperationsExtensions passes kotlin Array to Java varargs, so Array of array is passed to database, and fails.

inline fun <reified T> JdbcOperations.queryForObject(sql: String, args: Array<out Any>): T? =
		queryForObject(sql, T::class.java, args) as T

https://github.com/spring-projects/spring-framework/blob/v5.3.2/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt#L57-L58

should be

inline fun <reified T> JdbcOperations.queryForObject(sql: String, args: Array<out Any>): T? =
		queryForObject(sql, T::class.java, *args) as T

And, JdbcOperations.queryForList(sql: String, args: Array<out Any>): List<T> has the same problem.
https://github.com/spring-projects/spring-framework/blob/v5.3.2/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt#L89-L90J

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 23, 2020
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug labels Dec 23, 2020
@jhoeller jhoeller added this to the 5.3.3 milestone Dec 23, 2020
@sdeleuze sdeleuze removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 4, 2021
@sdeleuze sdeleuze changed the title JdbcOperationsExtensions need to convert Kotlin Array to Java varargs Fix JdbcOperations.queryForObject/queryForList extensions Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants