Reuse JdbcTemplate in NamedParameterJdbcTemplate

This commit makes sure to reuse an existing or auto-configured
`JdbcTemplate` when auto-configuring a `NamedParameterJdbcTemplate`.

This ensures that whatever customizations have been applied on the
`JdbcTemplate` are properly shared.

Closes gh-4945
This commit is contained in:
Stephane Nicoll
2017-06-01 10:08:13 +02:00
parent 42762a66b8
commit ad85902880
3 changed files with 85 additions and 16 deletions

View File

@@ -2932,6 +2932,9 @@ you can `@Autowire` them directly into your own beans:
}
----
TIP: The `NamedParameterJdbcTemplate` reuses the same `JdbcTemplate` instance behind the
scene. If more than one `JdbcTemplate` is defined and no primary candidate exists, the
`NamedParameterJdbcTemplate` is not auto-configured.
[[boot-features-jpa-and-spring-data]]