Skip to content

JdbcClient should be exposed JdbcTemplate #33306

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ public DefaultJdbcClient(NamedParameterJdbcOperations jdbcTemplate) {
this.namedParamOps = jdbcTemplate;
}

/**
* Expose the classic Spring JdbcTemplate to allow invocation of
* classic JDBC operations.
*/
@Override
public JdbcOperations getJdbcOperations() {
return this.classicOps;
}

/**
* 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.
*/
public JdbcTemplate getJdbcTemplate() {
Assert.state(this.classicOps instanceof JdbcTemplate, "No JdbcTemplate available");
return (JdbcTemplate) this.classicOps;
}

@Override
public StatementSpec sql(String sql) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
Expand Down Expand Up @@ -76,6 +77,19 @@ public interface JdbcClient {
*/
StatementSpec sql(String sql);

/**
* Expose the classic Spring JdbcTemplate to allow invocation of
* classic JDBC operations.
*/
JdbcOperations getJdbcOperations();

/**
* 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.
*/
JdbcTemplate getJdbcTemplate();

// Static factory methods

Expand Down