-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
NamedParameterJdbcOperations batchUpdate: column index is out of range #34153
Comments
It's a Spring Framework not Boot issue. Actual SQL is expanded by first if first param UPDATE users SET company = ? WHERE name IN (?, ?) with params:
if first param UPDATE users SET company = ? WHERE name IN (?) with params:
You should avoid using |
Is there any info in docs about it? Because I didn't find anything and fixed this problem randomly actually. |
Hello! Can be reproduced by next example:
For example I insert two rows using batchUpdate
and inserted vales are: Is this an expected behavior? |
Have you tried to bind tags as param directly?
|
Thank you!
|
Spring will treat it as single param instead of expanding it to multiple params, expanding is problematic for batch update with unfixed length |
Thanks for helping qualifying this issue @quaff, it looks like to me this is not a genuine issue so I will decline it. Please comment if you disagree. |
I'm using the latest Spring boot 3.4.1.
How to reproduce bug:
In general I want to use bulk update with one of query arguments is a collection (in this example argument :names is a list).
Also I sorted parameters with increasing size order of :names argument.
3) Try to execute it with different sized :names argument, for example:
And got something like:
But there is a twist.
If I sort arguments in decreasing order, like
everything is fine and test is successful.
I think there is some bug in SQL processing, when query with named parameters is transformed into a query with question marks.
You can see full example in repo: https://github.com/koalaa13/SpringBootIssueExample
Thank you in advance!
The text was updated successfully, but these errors were encountered: