@@ -211,19 +211,28 @@ the JDBC driver. If the count is not available, the JDBC driver returns a value
211211====
212212In such a scenario, with automatic setting of values on an underlying `PreparedStatement`,
213213the corresponding JDBC type for each value needs to be derived from the given Java type.
214- While this usually works well, there is a potential for issues (for example, with Map-contained
215- `null` values). Spring, by default, calls `ParameterMetaData.getParameterType` in such a
216- case, which can be expensive with your JDBC driver. You should use a recent driver
214+ While this usually works well, there is a potential for issues (for example, with
215+ Map-contained `null` values). Spring, by default, calls `ParameterMetaData.getParameterType`
216+ in such a case, which can be expensive with your JDBC driver. You should use a recent driver
217217version and consider setting the `spring.jdbc.getParameterType.ignore` property to `true`
218218(as a JVM system property or via the
219- xref:appendix.adoc#appendix-spring-properties[`SpringProperties`] mechanism) if you encounter
220- a performance issue (as reported on Oracle 12c, JBoss, and PostgreSQL).
221-
222- Alternatively, you might consider specifying the corresponding JDBC types explicitly,
223- either through a `BatchPreparedStatementSetter` (as shown earlier), through an explicit type
224- array given to a `List<Object[]>` based call, through `registerSqlType` calls on a
225- custom `MapSqlParameterSource` instance, or through a `BeanPropertySqlParameterSource`
226- that derives the SQL type from the Java-declared property type even for a null value.
219+ xref:appendix.adoc#appendix-spring-properties[`SpringProperties`] mechanism)
220+ if you encounter a specific performance issue for your application.
221+
222+ As of 6.1.2, Spring bypasses the default `getParameterType` resolution on PostgreSQL and
223+ MS SQL Server. This is a common optimization to avoid further roundtrips to the DBMS just
224+ for parameter type resolution which is known to make a very significant difference on
225+ PostgreSQL and MS SQL Server specifically, in particular for batch operations. If you
226+ happen to see a side effect e.g. when setting a byte array to null without specific type
227+ indication, you may explicitly set the `spring.jdbc.getParameterType.ignore=false` flag
228+ as a system property (see above) to restore full `getParameterType` resolution.
229+
230+ Alternatively, you could consider specifying the corresponding JDBC types explicitly,
231+ either through a `BatchPreparedStatementSetter` (as shown earlier), through an explicit
232+ type array given to a `List<Object[]>` based call, through `registerSqlType` calls on a
233+ custom `MapSqlParameterSource` instance, through a `BeanPropertySqlParameterSource`
234+ that derives the SQL type from the Java-declared property type even for a null value, or
235+ through providing individual `SqlParameterValue` instances instead of plain null values.
227236====
228237
229238
0 commit comments