本文整理汇总了Java中org.springframework.jdbc.core.namedparam.ParsedSql类的典型用法代码示例。如果您正苦于以下问题:Java ParsedSql类的具体用法?Java ParsedSql怎么用?Java ParsedSql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParsedSql类属于org.springframework.jdbc.core.namedparam包,在下文中一共展示了ParsedSql类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processMethodParameters
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的package包/类
private void processMethodParameters(List<ParameterProperties> parameterProperties) {
ParsedSql parsedSQL = NamedParameterUtils.parseSqlStatement(query);
try {
parametersNames = (List<String>) getParametersMethod.invoke(parsedSQL);
for (int i = 0; i < parametersNames.size(); i++) {
ParameterProperties properties = parameterProperties.get(i);
QueryParameterProcessor processor = QueryParameterProcessorFactory
.getQueryParameterProcessor(properties);
parameterMethodsList.add(processor);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
示例2: updateNamed
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
示例3: getParsedSql
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的package包/类
/**
* Obtain a parsed representation of this operation's SQL statement.
* <p>Typically used for named parameter parsing.
*/
protected ParsedSql getParsedSql() {
synchronized (this.parsedSqlMonitor) {
if (this.cachedSql == null) {
this.cachedSql = NamedParameterUtils.parseSqlStatement(getSql());
}
return this.cachedSql;
}
}
示例4: updateByNamedParam
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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;
}
示例5: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
示例6: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
示例7: processStreamList
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
示例8: executeByNamedParam
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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));
}
示例9: getParsedSql
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected ParsedSql getParsedSql(String sql) {
// the point of this class is to avoid parsing so if somebody tries to parse then we forgot to
// override a method
throw new UnsupportedOperationException("parsing SQL is not supported");
}
示例10: openCursor
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
}
示例11: executeByNamedParam
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}
示例12: executeByNamedParam
import org.springframework.jdbc.core.namedparam.ParsedSql; //导入依赖的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);
}