List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource MapSqlParameterSource
public MapSqlParameterSource(String paramName, @Nullable Object value)
From source file:com.exploringspatial.dao.impl.CodeDefinitionDaoImpl.java
@Override public List<CodeDefinition> find(Long codeCategoryPk) { final String sql = selectSQL.concat("WHERE CODE_CATEGORY_PK = :codeCategoryPk ORDER BY CODE"); final MapSqlParameterSource params = new MapSqlParameterSource("codeCategoryPk", codeCategoryPk) .addValue("codeCategoryPk", codeCategoryPk); return jdbcTemplate.query(sql, params, new CodeDefinitionRowMapper()); }
From source file:airport.database.services.chat.ChatDaoImpl.java
@Override public void addMessage(User user, String text, Timestamp timestampMessage) { SqlParameterSource parameterUser = new MapSqlParameterSource(PARAMETER_SQL_QUERY_LOGIN, user.getLogin()); int numberUser = jdbcTemplate.queryForObject(SQL_QUERY_SEEK_USER, parameterUser, Integer.class); MapSqlParameterSource parameterMessage = new MapSqlParameterSource(); parameterMessage.addValue(PARAMETER_SQL_QUERY_USER_ID, numberUser); parameterMessage.addValue(PARAMETER_SQL_QUERY_TEXT, text); parameterMessage.addValue(PARAMETER_SQL_QUERY_DATE, timestampMessage); jdbcTemplate.update(SQL_QUERY_ADD_MESSAGE, parameterMessage); if (LOG.isInfoEnabled()) { LOG.info(/*w w w. ja v a 2 s .com*/ "add message. User : " + user + ". Text : " + text + ". Time : " + timestampMessage.toString()); } }
From source file:org.string_db.jdbc.ProteinRepositoryJdbc.java
@Override public Map<Integer, String> loadProteinPreferredNames(Integer speciesId) { return queryProcessor.selectTwoColumns("protein_id", "preferred_name", "items.proteins", TwoColumnRowMapper.<Integer, String>uniqueValMapper(), "species_id = :species_id", new MapSqlParameterSource("species_id", speciesId)); }
From source file:com.exploringspatial.dao.impl.CodeCategoryDaoImpl.java
@Override public int delete(final Long codeCategoryPk) { final String sql = "DELETE FROM CODE_CATEGORY WHERE CODE_CATEGORY_PK = :codeCategoryPk"; final MapSqlParameterSource params = new MapSqlParameterSource("codeCategoryPk", codeCategoryPk); return jdbcTemplate.update(sql, params); }
From source file:com.neeti.neg.dao.impl.RegisterUserDaoImpl.java
@Override public int countOfUsersByUserName(String username) { SqlParameterSource namedParameters = new MapSqlParameterSource("groupname", username); int i = this.namedParameterJdbcTemplate.queryForObject(SQL_COUNTUSERS_BYUSERNAME, namedParameters, Integer.class); return i;/* ww w .j av a 2 s . com*/ }
From source file:pl.edu.agh.samm.db.impl.ActionExecutionDAO.java
@SuppressWarnings("unchecked") @Override//from w ww . j a va 2 s .c om public List<ActionExecution> getAllActionExecutions(String actionUri) { SqlParameterSource sps = new MapSqlParameterSource("actionUri", actionUri); return (List<ActionExecution>) getSimpleJdbcTemplate().getNamedParameterJdbcOperations() .query(SQL_QUERY_ACTION_EXECUTIONS, sps, new ActionExecutionExtractor()); }
From source file:com.eu.evaluation.server.service.impl.eva.UniqueEvaluate.java
public boolean evaluate(String evaluateItemHistoryID, AccessSystem accessSystem, String instanceClass, int instanceType, String instanceID) throws Exception { String debugInfo = "{0} = {1} , = {2} , = {3} , ID = {4}"; EvaluateItemHistory ev = evaluateItemHistoryDAO.get(evaluateItemHistoryID);// logger.debug(MessageFormat.format(debugInfo, new Object[] { "", accessSystem.getName(), ev.getObjectDictionary().getDisplayname(), ev.getFieldDictionary().getDisplayname(), instanceID })); Object entity = defaultDAO.findEvaluateData(instanceClass, instanceID, ev.getEvaluateVersion().getId(), accessSystem);//?? if (entity == null) { notPassMessage = "{0} {1} ? {2} ? {3} , ID {4} {5}"; notPassMessage = MessageFormat.format(notPassMessage, new Object[] { ev.getObjectDictionary().getDisplayname(), ev.getFieldDictionary().getDisplayname(), accessSystem.getName(), ev.getEvaluateVersion().getName(), instanceID, ev.getObjectDictionary().getDisplayname() }); return false; }/* w w w. ja va2 s . c o m*/ //??? String field = ev.getFieldDictionary().getPropertyName(); Object fieldValue = BeanUtils.getProperty(entity, field); //sql?? String jpql = "select count(*) from {0} t where t.{1} = :value and t.evaluateVersion.id = :evID and t.position = :position"; jpql = MessageFormat.format(jpql, new Object[] { instanceClass, field }); MapSqlParameterSource params = new MapSqlParameterSource("value", fieldValue); params.addValue("evID", ev.getEvaluateVersion().getId()); params.addValue("position", accessSystem.getCode()); long count = defaultDAO.executeCount(jpql, params); if (count > 1) {//1? notPassMessage = getErrorMsg(ev, entity, accessSystem); } logger.debug(MessageFormat.format(debugInfo, new Object[] { "?", accessSystem.getName(), ev.getObjectDictionary().getDisplayname(), ev.getFieldDictionary().getDisplayname(), instanceID })); return count <= 1; }
From source file:org.string_db.jdbc.ProteinRepositoryJdbc.java
@Override public Map<Integer, Set<String>> loadProteinNames(Integer speciesId, Set<String> sources) { String filter = "species_id = :species_id "; MapSqlParameterSource params = new MapSqlParameterSource("species_id", speciesId); if (sources != null && !sources.isEmpty()) { filter += " AND \"source\" IN (:sources)"; params.addValue("sources", sources); }/*from w w w .ja v a 2 s.c om*/ return queryProcessor.selectTwoColumns("protein_id", "protein_name", "items.proteins_names", multiValSqlRowMapper, filter, params); }
From source file:com.exploringspatial.dao.impl.CodeDefinitionDaoImpl.java
@Override public void insert(final CodeDefinition instance) { final String sql = "INSERT INTO CODE_DEFINITION (CODE_CATEGORY_PK, CODE, DEFINITION) VALUES (:codeCategoryPk, :code, :definition)"; final KeyHolder keyHolder = new GeneratedKeyHolder(); final MapSqlParameterSource params = new MapSqlParameterSource("codeCategoryPk", instance.getCodeCategoryPk()).addValue("code", instance.getCode()).addValue("definition", instance.getDefinition()); jdbcTemplate.update(sql, params, keyHolder); instance.setCodeDefinitionPk(keyHolder.getKey().longValue()); }
From source file:tomekkup.helenos.dao.ClusterConfigDao.java
public void delete(String alias) { jdbcTemplate.update(queriesProperties.getProperty("clusterconfig.delete"), new MapSqlParameterSource("alias", alias)); }