Example usage for org.springframework.jdbc.core.namedparam MapSqlParameterSource MapSqlParameterSource

List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource MapSqlParameterSource

Introduction

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

Prototype

public MapSqlParameterSource() 

Source Link

Document

Create an empty MapSqlParameterSource, with values to be added via addValue .

Usage

From source file:com.eu.evaluation.server.dao.eva.history.SimpleStatisticsDAO.java

/**
 * ??//from w w w  . j  ava  2  s .  com
 * @param ev
 * @param system
 * @return 
 */
public int delete(EvaluateVersion ev, AccessSystem system) {
    String jpql = "delete from SimpleStatistics t where t.evaluateVersion.id = :evid and t.position = :position";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("evid", ev.getId());
    params.addValue("position", system.getCode());
    return this.createQuery(jpql, params).executeUpdate();
}

From source file:fr.acxio.tools.agia.item.database.MapSqlParameterSourceProvider.java

@Override
public SqlParameterSource createSqlParameterSource(Map<String, Object> sItem) {
    MapSqlParameterSource aMapSqlParameterSource = new MapSqlParameterSource();
    aMapSqlParameterSource.addValues(sItem);
    return aMapSqlParameterSource;
}

From source file:im.dadoo.cas.server.dao.UserDao.java

public Optional<User> findById(int id) {
    Preconditions.checkArgument(id > 0, "id0");
    MapSqlParameterSource sps = new MapSqlParameterSource();
    sps.addValue("id", id);
    List<User> users = this.jdbcTemplate.query(FIND_BY_ID_SQL, sps, this.baseRowMapper);
    if (users != null && !users.isEmpty()) {
        return Optional.of(users.get(0));
    } else {/*from  w  ww . j  a va2  s.  c om*/
        return Optional.absent();
    }
}

From source file:pkg.StudentJDBCTemplateStoredProcedure.java

public Student getStudent(Integer id) {
    SqlParameterSource in = new MapSqlParameterSource().addValue("in_id", id);
    Map<String, Object> out = jdbcCall.execute(in);
    Student student = new Student();
    student.setId(id);/* w w w  .  ja  v  a2  s .  com*/
    student.setName((String) out.get("out_name"));
    student.setAge((Integer) out.get("out_age"));
    return student;
}

From source file:br.com.asisprojetos.DAO.TBRelatorioDiagnosticoDAO.java

/**
 * Busca cliente e suas filiais//w  w w. j  ava2  s  .  c om
 * @param codCliente
 * @return 
 **/
public String getHierarchyClients(String codCliente) {

    List<String> listCodCliente = Arrays.asList(StringUtils.split(codCliente, ','));

    String SQL = "SELECT" + " GROUP_CONCAT(COD_CLIENTE) " + " FROM " + " SPF_TBCLIENTE " + " WHERE "
            + " COD_MATRIZ IN ( :codCliente ) " + " AND COD_MATRIZ <> COD_CLIENTE ";

    MapSqlParameterSource namedParameters = new MapSqlParameterSource();

    namedParameters.addValue("codCliente", listCodCliente);

    String groupCliente = null;

    try {
        groupCliente = getNamedParameterJdbcTemplate().queryForObject(SQL, namedParameters, String.class);
    } catch (DataAccessException ex) {
        logger.error("Erro ao efetuar busca no banco de dados. Message {}", ex);
    }

    if (groupCliente == null) {
        return codCliente;
    } else {
        return codCliente + "," + getHierarchyClients(groupCliente);
    }

}

From source file:com.eu.evaluation.server.dao.eva.history.ResultDAO.java

/**
 * ?/*from  w  w w  .java2s. com*/
 *
 * @param ev
 * @return
 */
public List<Result> findUnFinished(EvaluateVersion ev, AccessSystem system) {
    String jpql = "select t from Result t where t.status = :status and t.evaluateVersion.id = :evID and t.position = :position";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("status", Result.STATUS_UNEVALUATE);
    params.addValue("evID", ev.getId());
    params.addValue("position", system.getCode());
    return this.query(jpql, params);
}

From source file:org.inbio.modeling.core.dao.impl.ConfigDAOImpl.java

@Override
public String findParameter(String parameterName) {
    String sqlStatement = null;/* w w w .  ja  v  a2 s. c om*/
    String parameterValue = null;
    MapSqlParameterSource args = null;

    sqlStatement = "SELECT value FROM " + this.table + " " + " WHERE name = :parameter_name";

    args = new MapSqlParameterSource();
    args.addValue("parameter_name", parameterName);

    parameterValue = getSimpleJdbcTemplate().queryForObject(sqlStatement, String.class, args);

    return parameterValue;
}

From source file:de.langmi.spring.batch.examples.readers.file.csv.FieldSetSqlParameterSourceProvider.java

/** {@inheritDoc} */
@Override/*w  ww  .  j a v  a2 s .  c  o m*/
public SqlParameterSource createSqlParameterSource(FieldSet item) {
    MapSqlParameterSource sps = new MapSqlParameterSource();
    for (Entry<Object, Object> entry : item.getProperties().entrySet()) {
        sps.addValue(entry.getKey().toString(), entry.getValue());
    }
    return sps;
}

From source file:com.eu.evaluation.server.dao.eva.NotNullEvaluateItemDAO.java

public NotNullEvaluateItem findTheMatching(ObjectDictionary od, FieldDictionary fd,
        Map<String, Object> otherMap) {
    String jpql = "select t from NotNullEvaluateItem t where t.fieldDictionary.id = :fdID ";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("fdID", fd.getId());
    List<NotNullEvaluateItem> result = this.query(jpql, params);
    if (result.isEmpty()) {
        return null;
    } else if (result.size() == 1) {
        return result.get(0);
    } else {//  w w w. j av a2 s.  c o  m
        throw new RuntimeException("" + fd.getObjectDictionary().getDisplayname() + " , "
                + fd.getDisplayname() + " ???");
    }
}

From source file:de.langmi.spring.batch.templates.importfile.generic.FieldSetSqlParameterSourceProvider.java

@Override
public SqlParameterSource createSqlParameterSource(FieldSet item) {
    // map FieldSet to MapSqlParameterSource
    MapSqlParameterSource sps = new MapSqlParameterSource();
    for (Entry<Object, Object> entry : item.getProperties().entrySet()) {
        sps.addValue(entry.getKey().toString(), entry.getValue());
    }//from  w  w  w.  j  ava2s. co  m

    return sps;

}