Skip to content

Commit

Permalink
Revise documentation notes on getParameterType performance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Sep 5, 2020
1 parent 40bf83c commit 939c76c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ public abstract class StatementCreatorUtils {
* completely, i.e. to never even attempt to retrieve {@link PreparedStatement#getParameterMetaData()}
* for {@link StatementCreatorUtils#setNull} calls.
* <p>The default is "false", trying {@code getParameterType} calls first and falling back to
* {@link PreparedStatement#setNull} / {@link PreparedStatement#setObject} calls based on well-known
* behavior of common databases. Spring records JDBC drivers with non-working {@code getParameterType}
* implementations and won't attempt to call that method for that driver again, always falling back.
* <p>Consider switching this flag to "true" if you experience misbehavior at runtime, e.g. with
* a connection pool setting back the {@link PreparedStatement} instance in case of an exception
* thrown from {@code getParameterType} (as reported on JBoss AS 7).
* {@link PreparedStatement#setNull} / {@link PreparedStatement#setObject} calls based on
* well-known behavior of common databases.
* <p>Consider switching this flag to "true" if you experience misbehavior at runtime,
* e.g. with connection pool issues in case of an exception thrown from {@code getParameterType}
* (as reported on JBoss AS 7) or in case of performance problems (as reported on PostgreSQL).
*/
public static final String IGNORE_GETPARAMETERTYPE_PROPERTY_NAME = "spring.jdbc.getParameterType.ignore";

Expand Down Expand Up @@ -266,7 +265,7 @@ private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, @
}
else if (databaseProductName.startsWith("DB2") ||
jdbcDriverName.startsWith("jConnect") ||
jdbcDriverName.startsWith("SQLServer")||
jdbcDriverName.startsWith("SQLServer") ||
jdbcDriverName.startsWith("Apache Derby")) {
sqlTypeToUse = Types.VARCHAR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/data-access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4449,7 +4449,7 @@ While this usually works well, there is a potential for issues (for example, wit
case, which can be expensive with your JDBC driver. You should use a recent driver
version and consider setting the `spring.jdbc.getParameterType.ignore` property to `true`
(as a JVM system property or in a `spring.properties` file in the root of your classpath)
if you encounter a performance issue -- for example, as reported on Oracle 12c (SPR-16139).
if you encounter a performance issue (as reported on Oracle 12c, JBoss and PostgreSQL).
Alternatively, you might consider specifying the corresponding JDBC types explicitly,
either through a 'BatchPreparedStatementSetter' (as shown earlier), through an explicit type
Expand Down

0 comments on commit 939c76c

Please sign in to comment.