NamedParameterJdbcTemplate provides accessor for classic JdbcTemplate

Issue: SPR-16241
This commit is contained in:
Juergen Hoeller
2017-11-29 15:38:21 +01:00
parent 6f73b8b200
commit b55a2631ba
2 changed files with 83 additions and 100 deletions

View File

@@ -105,14 +105,26 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
/**
* Expose the classic Spring JdbcTemplate to allow invocation of
* less commonly used methods.
* Expose the classic Spring JdbcTemplate operations to allow invocation
* of less commonly used methods.
*/
@Override
public JdbcOperations getJdbcOperations() {
return this.classicJdbcTemplate;
}
/**
* Expose the classic Spring {@link JdbcTemplate} itself, if available,
* in particular for passing it on to other {@code JdbcTemplate} consumers.
* <p>If sufficient for the purposes at hand, {@link #getJdbcOperations()}
* is recommended over this variant.
* @since 5.0.3
*/
public JdbcTemplate getJdbcTemplate() {
Assert.state(this.classicJdbcTemplate instanceof JdbcTemplate, "No JdbcTemplate available");
return (JdbcTemplate) this.classicJdbcTemplate;
}
/**
* Specify the maximum number of entries for this template's SQL cache.
* Default is 256.