@Override public <T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException { return result(query(psc, new RowMapperResultSetExtractor<>(rowMapper))); }
@Override public void query(PreparedStatementCreator psc, RowCallbackHandler rch) throws DataAccessException { query(psc, new RowCallbackHandlerResultSetExtractor(rch)); }
@Override public SqlRowSet queryForRowSet(String sql) throws DataAccessException { return result(query(sql, new SqlRowSetResultSetExtractor())); }
/** * Constructor to be used when initializing using a {@link DataSource}. * @param dataSource the DataSource to be used */ protected AbstractJdbcInsert(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); }
/** * Static factory method to create a new {@code BeanPropertyRowMapper} * (with the mapped class specified only once). * @param mappedClass the class that each row should be mapped to */ public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass) { return new BeanPropertyRowMapper<>(mappedClass); }
/** * Construct a new JdbcTemplate, given a DataSource to obtain connections from. * <p>Note: This will not trigger initialization of the exception translator. * @param dataSource the JDBC DataSource to obtain connections from */ public JdbcTemplate(DataSource dataSource) { setDataSource(dataSource); afterPropertiesSet(); }
/** * Create a new RowMapper for reading result objects from a single column. * @param requiredType the type that each result object is expected to match * @return the RowMapper to use * @see SingleColumnRowMapper */ protected <T> RowMapper<T> getSingleColumnRowMapper(Class<T> requiredType) { return new SingleColumnRowMapper<>(requiredType); }
/** * Set the fetch size for this RDBMS operation. This is important for processing * large result sets: Setting this higher than the default value will increase * processing speed at the cost of memory consumption; setting this lower can * avoid transferring row data that will never be read by the application. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize */ public void setFetchSize(int fetchSize) { this.jdbcTemplate.setFetchSize(fetchSize); }
/** * Set the maximum number of rows for this RDBMS operation. This is important * for processing subsets of large result sets, avoiding to read and hold * the entire result set in the database or in the JDBC driver. * <p>Default is 0, indicating to use the driver's default. * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows */ public void setMaxRows(int maxRows) { this.jdbcTemplate.setMaxRows(maxRows); }
/** * Create a new arg-type-based PreparedStatementSetter using the args and types passed in. * <p>By default, we'll create an {@link ArgumentTypePreparedStatementSetter}. * This method allows for the creation to be overridden by subclasses. * @param args object array with arguments * @param argTypes int array of SQLTypes for the associated arguments * @return the new PreparedStatementSetter to use */ protected PreparedStatementSetter newArgTypePreparedStatementSetter(Object[] args, int[] argTypes) { return new ArgumentTypePreparedStatementSetter(args, argTypes); }
/** * Create a new {@code SingleColumnRowMapper}. * <p>Consider using the {@link #newInstance} factory method instead, * which allows for specifying the required type once only. * @param requiredType the type that each result object is expected to match */ public SingleColumnRowMapper(Class<T> requiredType) { setRequiredType(requiredType); }
/** * Create a new factory with the given SQL and JDBC types. * @param sql the SQL statement to execute * @param types int array of JDBC types */ public PreparedStatementCreatorFactory(String sql, int... types) { this.sql = sql; this.declaredParameters = SqlParameter.sqlTypesToAnonymousParameterList(types); }
/** * Create a JdbcTemplate for the given DataSource. * Only invoked if populating the DAO with a DataSource reference! * <p>Can be overridden in subclasses to provide a JdbcTemplate instance * with different configuration, or a custom JdbcTemplate subclass. * @param dataSource the JDBC DataSource to create a JdbcTemplate for * @return the new JdbcTemplate instance * @see #setDataSource */ protected JdbcTemplate createJdbcTemplate(DataSource dataSource) { return new JdbcTemplate(dataSource); }
@Override public <T> List<T> query(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper) throws DataAccessException { return result(query(sql, args, argTypes, new RowMapperResultSetExtractor<>(rowMapper))); }
@Override public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException { return result(query(sql, args, argTypes, new SqlRowSetResultSetExtractor())); }
@Override public void query(String sql, RowCallbackHandler rch) throws DataAccessException { query(sql, new RowCallbackHandlerResultSetExtractor(rch)); }
/** * Static factory method to create a new {@code SingleColumnRowMapper} * (with the required type specified only once). * @param requiredType the type that each result object is expected to match * @since 4.1 */ public static <T> SingleColumnRowMapper<T> newInstance(Class<T> requiredType) { return new SingleColumnRowMapper<>(requiredType); }
/** * Specify the type that the result object is required to match. * <p>If not specified, the result value will be exposed as * returned by the JDBC driver. */ public void setResultType(Class<T> resultType) { this.rowMapper.setRequiredType(resultType); }
/** * Constructor to be used when initializing using a {@link DataSource}. * @param dataSource the DataSource to be used */ protected AbstractJdbcCall(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); }
@Override public <T> List<T> query(String sql, RowMapper<T> rowMapper) throws DataAccessException { return result(query(sql, new RowMapperResultSetExtractor<>(rowMapper))); }