Package org.springframework.jdbc.core.namedparam

Examples of org.springframework.jdbc.core.namedparam.ParsedSql


   * matching named parameters specified in the SQL statement
   * @return the number of rows affected by the update
   */
  public int updateByNamedParam(Map<String, ?> paramMap) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params));
    checkRowsAffected(rowsAffected);
View Full Code Here


   * @param generatedKeyHolder KeyHolder that will hold the generated keys
   * @return the number of rows affected by the update
   */
  public int updateByNamedParam(Map<String, ?> paramMap, KeyHolder generatedKeyHolder) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params), generatedKeyHolder);
    checkRowsAffected(rowsAffected);
View Full Code Here

  private int[] doExecuteBatchUpdateWithNamedParameters(String sql, final SqlParameterSource[] batchArgs) {
    if (batchArgs.length <= 0) {
      return new int[] {0};
    }
    final ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
    return getJdbcOperations().batchUpdate(
        sqlToUse,
        new BatchPreparedStatementSetter() {
View Full Code Here

   * matching named parameters specified in the SQL statement
   * @return the number of rows affected by the update
   */
  public int updateByNamedParam(Map paramMap) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params));
    checkRowsAffected(rowsAffected);
View Full Code Here

   * @param generatedKeyHolder KeyHolder that will hold the generated keys
   * @return the number of rows affected by the update
   */
  public int updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params), generatedKeyHolder);
    checkRowsAffected(rowsAffected);
View Full Code Here

   * @return a List of objects, one per row of the ResultSet. Normally all these
   * will be of the same class, although it is possible to use different types.
   */
  public List executeByNamedParam(Map paramMap, Map context) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    RowMapper rowMapper = newRowMapper(params, context);
     return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
View Full Code Here

     */
    @Override
    public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
        // substitute named params,
        // see NamedParameterJdbcTemplate#getPreparedStatementCreator(String sql, SqlParameterSource paramSource)
        ParsedSql parsedSql = parseSqlStatement(sql);
        String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
        Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
        List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, paramSource);
        PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
        PreparedStatementCreator psc = pscf.newPreparedStatementCreator(params);
View Full Code Here

    @Override
    public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
        final PreparedStatement stmt;
        // substitute named params,
        // see NamedParameterJdbcTemplate#getPreparedStatementCreator(String sql, SqlParameterSource paramSource)
        ParsedSql parsedSql = parseSqlStatement(sql);
        String sqlToUse = substituteNamedParameters(parsedSql, params);
        stmt = con.prepareStatement(sqlToUse);
        Object[] parArray = buildValueArray(parsedSql, params, null);
        List<SqlParameter> parList = buildSqlParameterList(parsedSql, params);
        for(int i = 0; i < parArray.length; i++) {
View Full Code Here

   * @return a List of objects, one per row of the ResultSet. Normally all these
   * will be of the same class, although it is possible to use different types.
   */
  public List<T> executeByNamedParam(Map<String, ?> paramMap, Map<?, ?> context) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    RowMapper<T> rowMapper = newRowMapper(params, context);
     return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
View Full Code Here

   * @return a List of objects, one per row of the ResultSet. Normally all these
   * will be of the same class, although it is possible to use different types.
   */
  public List<T> executeByNamedParam(Map<String, ?> paramMap, Map context) throws DataAccessException {
    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    RowMapper<T> rowMapper = newRowMapper(params, context);
     return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.namedparam.ParsedSql

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.