-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Avoid repeated getParameterType calls for setNull with Oracle 12c driver [SPR-14574] #19143
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
Comments
Tom Jahncke commented This relates to #18398 and #15726. To work around this challenge we set "spring.jdbc.getParameterType.ignore" to true. |
Juergen Hoeller commented I'm afraid there is not much we can do here, since we lack the contextual information to properly cache statement objects. This is better done inside a connection pool with statement pooling turned on, which may also cache retrieved If there is anything we can cleanly do to avoid repeated |
Tom Jahncke commented Juergen, thank you for your quick response and research. I also didn't think there was a facility for you to accomplish what I requested, but I wasn't sure. One possibility might be: if the equal statement of a preparedStatement allowed you to keep a cache of the statements that have already had the correct sqlType determine for a given parameter. I wasn't aware of statement pooling. I'll try that and let you know the outcome. I have also thought about changing at least my insert statements to be by parameter name instead of parameter index using BeanPropertySqlParameterSource. One gotta ya with doing this is we have enum attributes on the bean. Today with the parameters being by index I loop through the set of parameters prior to calling Spring and convert them to the correct persist primitive data type / value. I did find a similar challenge (without a solid resolution) on stack overflow . I did think about extending BeanPropertySqlParamterSoure to address this, however, I would love a more elegant solution. |
Juergen Hoeller commented Revised for 4.3.3 and 4.2.8 now: |
Juergen Hoeller commented It would be great if you could give a recent |
Tom Jahncke commented I have tried out version 4.2.8.BUILD-SNAPSHOT and it works as expected, thanks. Details of what I found are:
|
Tom Jahncke opened SPR-14574 and commented
In the StatementCreatorUtils class, setNull method, the call to ps.getParameterMetaData().getParameterType(paramIndex), happens for every null parameter.
If the database is not local to where the Java application is running the overhead of this repeated statement is a significant performance hit due to the latency overhead of each DB operation. For example, we are performing a batch insert from a remote site back to the main enterprise system of thousands of records each with several nulls.
Not sure how feasible it is, but could you cache the sql type for a prepared statement / parameter index so once it is determine it does not have to be derive again?
Thanks!!
Affects: 4.2.5
Issue Links:
Backported to: 4.2.8
The text was updated successfully, but these errors were encountered: