当前位置: 首页>>代码示例>>Java>>正文


Java ParsedSql类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:17,代码来源:JdbcByNameRepositoryQuery.java

示例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);

}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:10,代码来源:BaseJdbcDaoImpl.java

示例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;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SqlOperation.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SqlUpdate.java

示例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);
}
 
开发者ID:youseries,项目名称:ureport,代码行数:9,代码来源:DatasourceServletAction.java

示例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);
}
 
开发者ID:javen-hao,项目名称:osmp,代码行数:11,代码来源:BaseTemplate.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:ElsqlProducer.java

示例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));
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:9,代码来源:MappingSqlQuery.java

示例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");
}
 
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:10,代码来源:OracleNamedParameterJdbcTemplate.java

示例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);
		}

	}
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:54,代码来源:NamedJdbcCursorItemReader.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:SqlQuery.java

示例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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:SqlQuery.java


注:本文中的org.springframework.jdbc.core.namedparam.ParsedSql类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。