Java Code Examples for org.springframework.jdbc.core.namedparam.NamedParameterUtils#parseSqlStatement()

The following examples show how to use org.springframework.jdbc.core.namedparam.NamedParameterUtils#parseSqlStatement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionImpl.java    From gemini with Apache License 2.0 5 votes vote down vote up
private PreparedStatement getPreparedStatement(String sql, @Nullable Map<String, ?> parameters, boolean returnKeys) throws SQLException {
    SqlParameterSource paramSource = new MapSqlParameterSource(parameters);
    ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
    PreparedStatementCreatorFactory psCreatorFactory = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
    psCreatorFactory.setReturnGeneratedKeys(returnKeys);
    PreparedStatementCreator psCreator = psCreatorFactory.newPreparedStatementCreator(params);
    PreparedStatement preparedStatement = psCreator.createPreparedStatement(connection);
    logger.debug(preparedStatement.unwrap(PreparedStatement.class).toString());
    return preparedStatement;
}
 
Example 2
Source File: SqlOperation.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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(resolveSql());
		}
		return this.cachedSql;
	}
}
 
Example 3
Source File: SqlOperation.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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(resolveSql());
		}
		return this.cachedSql;
	}
}
 
Example 4
Source File: SqlOperation.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
	}
}
 
Example 5
Source File: DatasourceServletAction.java    From ureport with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: SqlOperation.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
	}
}
 
Example 7
Source File: SqlOperation.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
	}
}