本文整理汇总了Java中org.springframework.jdbc.core.namedparam.NamedParameterUtils.buildValueArray方法的典型用法代码示例。如果您正苦于以下问题:Java NamedParameterUtils.buildValueArray方法的具体用法?Java NamedParameterUtils.buildValueArray怎么用?Java NamedParameterUtils.buildValueArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.namedparam.NamedParameterUtils
的用法示例。
在下文中一共展示了NamedParameterUtils.buildValueArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateNamed
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
public <T> int updateNamed(String namedSql, T bean) {
String sql = NamedParameterUtils.parseSqlStatementIntoString(namedSql);
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(namedSql);
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(bean);
List<SqlParameter> params = NamedParameterUtils.buildSqlParameterList(parsedSql, source);
Object[] args = NamedParameterUtils.buildValueArray(parsedSql, source, params);
return jdbcTemplate.update(sql, args);
}
示例2: updateByNamedParam
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
/**
* Generic method to execute the update given named parameters.
* All other update methods invoke this method.
* @param paramMap Map of parameter name to parameter object,
* 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);
return rowsAffected;
}
示例3: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected PreparedStatementCreator getPreparedStatementCreator(String sql, SqlParameterSource paramSource) {
ParsedSql parsedSql = NamedParameterUtils.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);
return pscf.newPreparedStatementCreator(params);
}
示例4: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected PreparedStatementCreator getPreparedStatementCreator(String sql, Map<String,Object> paramMap) {
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
ParsedSql parsedSql = NamedParameterUtils.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);
pscf.setReturnGeneratedKeys(true);
return pscf.newPreparedStatementCreator(params);
}
示例5: processStreamList
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected void processStreamList(Exchange exchange, String sql, SqlParameterSource param) throws Exception {
// spring JDBC to parse the SQL and build the prepared statement creator
// this is what NamedJdbcTemplate does internally
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, param);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, param, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, param);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
PreparedStatementCreator statementCreator = pscf.newPreparedStatementCreator(params);
processStreamList(exchange, statementCreator, sqlToUse);
}
示例6: updateNamedMap
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
public int[] updateNamedMap(String namedSql, List<Map<String, Object>> paramMaps) {
String sql = NamedParameterUtils.parseSqlStatementIntoString(namedSql);
List<Object[]> batchArgs = new ArrayList<Object[]>();
for (Map<String, Object> paramMap : paramMaps) {
Object[] args = NamedParameterUtils.buildValueArray(namedSql, paramMap);
batchArgs.add(args);
}
return jdbcTemplate.batchUpdate(sql, batchArgs);
}
示例7: executeByNamedParam
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
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());
return query(newPreparedStatementCreator(sqlToUse, params));
}
示例8: openCursor
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
@Override
protected void openCursor(Connection con) {
//MyParsedSqlDel parsedSql = getParsedSql(sql);
//String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql.getDelegate(), paramSource);
//String theSql = sqlToUse;
try {
// if (isUseSharedExtendedConnection()) {
// preparedStatement = con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
// ResultSet.HOLD_CURSORS_OVER_COMMIT);
// }
// else {
// preparedStatement = con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
// }
// applyStatementSettings(preparedStatement);
// if (this.preparedStatementSetter != null) {
//
//
// preparedStatementSetter.setValues(preparedStatement);
//
//
//
//
//
// }
// this.rs = preparedStatement.executeQuery();
ParsedSql parsedSql1 = this.getParsedSql(sql).getDelegate();
String sqlToUse1 = NamedParameterUtils.substituteNamedParameters(parsedSql1, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql1, paramSource, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql1, paramSource);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse1, declaredParameters);
pscf.setResultSetType( ResultSet.TYPE_FORWARD_ONLY );
pscf.setUpdatableResults(false);
PreparedStatementCreator preparedStatementCreator = pscf.newPreparedStatementCreator(params);
//con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
preparedStatement = preparedStatementCreator.createPreparedStatement(con);
this.rs = preparedStatement.executeQuery();
handleWarnings(preparedStatement);
}
catch (SQLException se) {
close();
throw getExceptionTranslator().translate("Executing query", getSql(), se);
}
}
示例9: executeByNamedParam
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
/**
* Central execution method. All named parameter execution goes through this method.
* @param paramMap parameters associated with the name specified while declaring
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
* type. The ordering of parameters is not significant since they are supplied in a
* SqlParameterMap which is an implementation of the Map interface.
* @param context contextual information passed to the {@code mapRow}
* callback method. The JDBC operation itself doesn't rely on this parameter,
* but it can be useful for creating the objects of the result list.
* @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);
}
示例10: executeByNamedParam
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
/**
* Central execution method. All named parameter execution goes through this method.
* @param paramMap parameters associated with the name specified while declaring
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
* type. The ordering of parameters is not significant since they are supplied in a
* SqlParameterMap which is an implementation of the Map interface.
* @param context contextual information passed to the {@code mapRow}
* callback method. The JDBC operation itself doesn't rely on this parameter,
* but it can be useful for creating the objects of the result list.
* @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);
}