List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource MapSqlParameterSource
public MapSqlParameterSource()
From source file:com.esa.infocontrol.utils.RequestParametersUtils.java
public static MapSqlParameterSource getQueryParameters(String id, Map<String, List<String>> queryParams) { MapSqlParameterSource sqlParams = new MapSqlParameterSource(); for (Map.Entry<String, List<String>> entry : queryParams.entrySet()) { LOG.info(entry.getKey() + " -> " + entry.getValue()); if (!entry.getKey().equalsIgnoreCase("id")) { sqlParams.addValue(entry.getKey(), entry.getValue()); }//from w w w . j av a2 s. c o m } if (id != null) { sqlParams.addValue("id", id); } return sqlParams; }
From source file:com.opengamma.elsql.SpringSqlParamsTest.java
public void test_constructor_Map() { MapSqlParameterSource source = new MapSqlParameterSource(); source.addValue("a", "b"); SpringSqlParams test = new SpringSqlParams(source); assertEquals(true, test.contains("a")); assertEquals("b", test.get("a")); assertEquals(false, test.contains("x")); assertEquals(null, test.get("x")); }
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.EvaluateVersionDAO.java
public List<EvaluateVersion> find(EvaluateVersion ev, Calendar startDate, Calendar endDate) { String jpql = "select t from EvaluateVersion t where 1=1"; MapSqlParameterSource params = new MapSqlParameterSource(); if (!StringUtils.isBlank(ev.getId())) { jpql += " and t.id = :id"; params.addValue("id", ev.getId()); }//from w ww. j a v a 2 s . co m if (!StringUtils.isBlank(ev.getName())) { jpql += " and t.name like :name"; params.addValue("name", "'" + ev.getName() + "'"); } if (startDate != null) { jpql += " and t.createDate >= :startDate"; params.addValue("startDate", startDate); } if (endDate != null) { jpql += " and t.createDate <= :endDate"; params.addValue("endDate", endDate); } return this.query(jpql, params); }
From source file:com.perry.infrastructure.call.CallDaoServiceImpl.java
@Override public List<Call> getByIds(List<Long> ids) { MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("call_ids", ids); String sql = "select * from calls where call_id in (:call_ids)"; List<Call> callList = namedParameterJdbcTemplate.query(sql, params, new CallRowMapper()); return callList; }
From source file:com.eu.evaluation.server.dao.eva.EvaluateItemTemplateDAO.java
public EvaluateItemTemplate findTheMatching(EvaluateTypeEnum type, ObjectDictionary od, FieldDictionary fd) { String jpql = "select t from EvaluateItemTemplate t where t.evaluateTypeEnum = :evaluateTypeEnum "; MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("evaluateTypeEnum", type); List<EvaluateItemTemplate> result = this.query(jpql, params); if (result.isEmpty()) { throw new RuntimeException("" + type.getName() + " ??"); } else if (result.size() == 1) { return result.get(0); } else {/* w w w. j a va 2 s.co m*/ jpql += "and t.objectDictionary.id = :odID "; params.addValue("odID", od.getId()); result = this.query(jpql, params); if (result.size() == 1) { return result.get(0); } else { jpql += "and t.fieldDictionary.id = :fdID "; params.addValue("fdID", fd.getId()); result = this.query(jpql, params); if (result.size() == 1) { return result.get(0); } else if (result.isEmpty()) { throw new RuntimeException("" + type.getName() + " ?" + od.getDisplayname() + "?" + fd.getDisplayname() + "??"); } else { throw new RuntimeException( "" + type.getName() + " ?" + od.getDisplayname() + "?" + fd.getDisplayname() + "???"); } } } }
From source file:fr.acxio.tools.agia.item.database.FieldSetSqlParameterSourceProvider.java
@Override public SqlParameterSource createSqlParameterSource(FieldSet sItem) { MapSqlParameterSource aMapSqlParameterSource = new MapSqlParameterSource(); if (sItem != null) { mapFieldSet(aMapSqlParameterSource, sItem, 0); }// w w w . j ava 2s . c om return aMapSqlParameterSource; }
From source file:com.stehno.fixture.PetParamMapper.java
@Override public SqlParameterSource mapByName(final AnnotatedArgument[] args) { final Pet pet = (Pet) args[0].getValue(); final MapSqlParameterSource parameterSource = new MapSqlParameterSource(); parameterSource.addValue("id", pet.getId()); parameterSource.addValue("name", pet.getName()); parameterSource.addValue("species", pet.getSpecies().name()); return parameterSource; }
From source file:fr.acxio.tools.agia.item.database.ListFieldSetSqlParameterSourceProvider.java
@Override public SqlParameterSource createSqlParameterSource(List<FieldSet> sItem) { MapSqlParameterSource aMapSqlParameterSource = new MapSqlParameterSource(); if (sItem != null) { for (int aFieldSetIdx = 0; aFieldSetIdx < sItem.size(); aFieldSetIdx++) { FieldSet aFieldSet = sItem.get(aFieldSetIdx); mapFieldSet(aMapSqlParameterSource, aFieldSet, aFieldSetIdx); }// w w w . j a v a 2s. c o m } return aMapSqlParameterSource; }
From source file:com.eu.evaluation.server.dao.eva.history.UnPassedEvaluatedDataDAO.java
/** * ??//from w w w. j a va 2 s. co m * @param ev * @param system * @return */ public int deleteByVersionAndPosition(EvaluateVersion ev, AccessSystem system) { String jpql = "delete from UnPassedEvaluatedData 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(); }