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

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

Introduction

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

Prototype

public MapSqlParameterSource addValue(String paramName, @Nullable Object value) 

Source Link

Document

Add a parameter to this parameter source.

Usage

From source file:com.eu.evaluation.server.dao.dictionary.ObjectDictionaryDAO.java

public ObjectDictionary findByDisplayName(String displayName) {
    String jpql = "select t from ObjectDictionary t where t.displayname = :displayname and t.valid = :valid";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("displayname", displayName);
    params.addValue("valid", true);
    List<ObjectDictionary> result = this.query(jpql, params);
    if (result.isEmpty()) {
        return null;
    } else if (result.size() == 1) {
        return result.get(0);
    } else {//from  w  w w. j a va2  s. co m
        throw new RuntimeException("?? " + displayName
                + " valid1??");
    }
}

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 w  w . j  a  va 2  s.  co m*/
        return Optional.absent();
    }
}

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

public Optional<User> findByName(String name) {
    Preconditions.checkNotNull(name, "name?null");
    MapSqlParameterSource sps = new MapSqlParameterSource();
    sps.addValue("name", name);
    List<User> users = this.jdbcTemplate.query(FIND_BY_NAME_SQL, sps, this.baseRowMapper);
    if (users != null && !users.isEmpty()) {
        return Optional.of(users.get(0));
    } else {//from w ww.  j av a  2 s  .  c  o  m
        return Optional.absent();
    }
}

From source file:com.eu.evaluation.server.dao.dictionary.FieldDictionaryDAO.java

public List<String> findByObject(String objectID) {
    String jpql = "select t.fieldName from FieldDictionary t where t.objectDictionary.id = :oid and t.valid =:valid";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("oid", objectID);
    params.addValue("valid", true);
    return this.createQuery(jpql, params).getResultList();
}

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

/**
 * ?//  w w w .ja va  2s . 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:com.eu.evaluation.server.dao.eva.history.SimpleStatisticsDAO.java

/**
 * ??/* w  ww.  j  a v  a2  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:com.eu.evaluation.server.dao.eva.history.ResultDAO.java

public PageData<Result> findUnPassed(EvaluateVersion ev, AccessSystem system, int pageNo, int pageSize) {
    String jpql = "select r from Result r " + "where r.evaluateVersion.id = :evid "
            + "and r.position = :position " + "and r.status =:status "
            + "order by r.instanceType , r.instanceId , r.itemHistory.evaluateTypeEnum";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("evid", ev.getId());
    params.addValue("position", system.getCode());
    params.addValue("status", Result.STATUS_FAILURE);
    return this.query(jpql, params, pageNo, pageSize);
}

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

/**
 * ????/* ww  w.ja  v  a 2s.  co m*/
 * @param evaulateVersionID
 * @param position
 * @param entityEnum
 * @return 
 */
public List<SimpleStatistics> find(String evaulateVersionID, String position, EntityEnum entityEnum) {
    String jpql = "select t from SimpleStatistics t where t.evaluateVersion.id = :evid and t.position = :position and t.instanceType = :instanceType";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("evid", evaulateVersionID);
    params.addValue("position", position);
    params.addValue("instanceType", entityEnum.getInstanceType());
    return this.query(jpql, params);
}

From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ParametreCommunalJdbcRTaxPPDao.java

@Override
public BigDecimal getTauxCentimes(int annee, int noOFSCommune) {
    String sql = "SELECT PPC.PIC_N_TAUX / 100 " + FROM;
    MapSqlParameterSource param = new MapSqlParameterSource();
    param.addValue("periode", annee);
    param.addValue("noOFS", noOFSCommune);
    return this.getSimpleJdbcTemplate().queryForObject(sql, BigDecimal.class, param);
}

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

/**
 * ?????SimpleStatistics/*ww w .jav  a2  s. c o  m*/
 * @param ev
 * @param system
 * @return 
 */
public List<SimpleStatistics> groupToSimpleStatistics(EvaluateVersion ev, AccessSystem system) {
    String jpql = "select new SimpleStatistics(t.instanceType , t.instanceClass , h.evaluateTypeEnum)"
            + " from Result t , EvaluateItemHistory h "
            + "where t.itemHistory.id = h.id and t.evaluateVersion.id = :evid and t.position = :position "
            + "group by t.instanceType , t.instanceClass , h.evaluateTypeEnum";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("evid", ev.getId());
    params.addValue("position", system.getCode());
    return this.createQuery(jpql, params).getResultList();
}