Example usage for org.springframework.jdbc.core.namedparam NamedParameterUtils buildValueArray

List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterUtils buildValueArray

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam NamedParameterUtils buildValueArray.

Prototype

public static Object[] buildValueArray(String sql, Map<String, ?> paramMap) 

Source Link

Document

Convert a Map of named parameter values to a corresponding array.

Usage

From source file:com.weir.schedule.dao.SimpleJob.java

/**
 * <p> Called by the/*from   www .  ja  va 2s .  c o m*/
 * <code>{@link org.quartz.Scheduler}</code> when a
 * <code>{@link org.quartz.Trigger}</code> fires that is associated with the
 * <code>Job</code>. </p>
 *
 * @throws JobExecutionException if there is an exception while executing
 * the job.
 */
@Override
public void execute(JobExecutionContext jec) throws JobExecutionException {
    JobDataMap jdm = jec.getJobDetail().getJobDataMap();

    //        for (Entry<String, Object> et : jdm.entrySet()) {
    //            _log.debug("key:" + et.getKey() + "\tvalue:" + et.getValue());
    //        }

    if (!jdm.containsKey(ParamKey._conditionSQL)) {
        return;
    }
    if (!jdm.containsKey(ParamKey._sourceSQL)) {
        return;
    }
    if (!jdm.containsKey(ParamKey._targetSQL)) {
        return;
    }
    if (jdm.containsKey(ParamKey._isReverse)) {
        this.isReverse = Boolean.valueOf(jdm.getString(ParamKey._isReverse));
    }

    sourceSQL = jdm.getString(ParamKey._sourceSQL);
    Map<String, String> p = new HashMap<String, String>();
    //        p.put("name", "my name");
    p.put("name", "my name");
    //        ????????
    String sql = NamedParameterUtils.parseSqlStatementIntoString(sourceSQL);
    //        Map??????
    Object[] args = NamedParameterUtils.buildValueArray(sourceSQL, p);

    log.debug("++++++++++++++++++++++++++++++++++++++++++++++++");
    log.debug(sql);
    for (int i = 0; i < args.length; i++) {
        log.debug(args[i].toString());
    }
    log.debug("================================================");
}