List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value)
From source file:com.esa.infocontrol.data.jdbc.BaseDAO.java
private static String[] getQuery(String queryName, int version) { String[] queryData = new String[2]; if (queryName.charAt(0) == '$') { queryName = queryName.substring(1); LOG.debug("Getting query named: {}", queryName); MapSqlParameterSource params = new MapSqlParameterSource("name", queryName); params.addValue("version", version); DataArrayWrapper data = BaseDAO.getList("qry_queries", version, null, params); StringBuilder sb = new StringBuilder(); for (DataRow row : data.getDataArray()) { sb.append(row.get(0));//from www . jav a 2 s . c o m sb.append(" "); } queryData[0] = data.getDataArray().get(0).get(1); queryData[1] = sb.toString(); } else { queryData[0] = dataSourceName; queryData[1] = queries.get(queryName); } System.out.println(Arrays.toString(queryData)); return queryData; }
From source file:alfio.util.EventUtil.java
private static MapSqlParameterSource buildTicketParams(int eventId, Date creation, Optional<TicketCategory> tc, int srcPriceCts, MapSqlParameterSource ps, Ticket.TicketStatus ticketStatus) { return ps.addValue("uuid", UUID.randomUUID().toString()).addValue("creation", creation) .addValue("categoryId", tc.map(TicketCategory::getId).orElse(null)).addValue("eventId", eventId) .addValue("status", ticketStatus.name()).addValue("srcPriceCts", srcPriceCts); }
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 ww.j a v a 2 s.c o m*/ } if (id != null) { sqlParams.addValue("id", id); } return sqlParams; }
From source file:io.lavagna.service.PermissionService.java
private static MapSqlParameterSource[] addProjectId(MapSqlParameterSource[] s, int projectId) { for (MapSqlParameterSource param : s) { param.addValue("projectId", projectId); }// w w w . j a v a 2s .c o m return s; }
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.eva.history.UnPassedEvaluatedDataDAO.java
/** * ??//ww w .j a va2 s. c om * @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(); }
From source file:com.eu.evaluation.server.dao.eva.history.UnPassedEvaluatedDataDAO.java
/** * ??SimpleStatistics//w w w . j a va2s.co m * @param ev * @param system * @return */ public List<SimpleStatistics> countToSimpleStatistics(EvaluateVersion ev, AccessSystem system) { String jpql = "select new SimpleStatistics(t.evaluateTypeEnum , t.instanceType , t.instanceClass , count(t.instanceType)) " + "from UnPassedEvaluatedData t " + "where t.evaluateVersion.id = :evid and t.position = :position " + "group by t.evaluateTypeEnum , t.instanceType , t.instanceClass"; MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("evid", ev.getId()); params.addValue("position", system.getCode()); return this.createQuery(jpql, params).getResultList(); }
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 a v a2 s . c om throw new RuntimeException("" + fd.getObjectDictionary().getDisplayname() + " , " + fd.getDisplayname() + " ???"); } }
From source file:com.eu.evaluation.server.dao.eva.UniqueEvaluateItemDAO.java
public UniqueEvaluateItem findTheMatching(ObjectDictionary od, FieldDictionary fd, Map<String, Object> otherMap) { String jpql = "select t from UniqueEvaluateItem t where t.fieldDictionary.id = :fdID "; MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("fdID", fd.getId()); List<UniqueEvaluateItem> 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 v a 2 s . c o m throw new RuntimeException("" + fd.getObjectDictionary().getDisplayname() + " , " + fd.getDisplayname() + " ??"); } }
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; }