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 CodeDefinition get(final Long codeDefinitionPk) { final String sql = selectSQL.concat("WHERE CODE_DEFINITION_PK = :codeDefinitionPk"); final MapSqlParameterSource params = new MapSqlParameterSource("codeDefinitionPk", codeDefinitionPk); final List<CodeDefinition> results = jdbcTemplate.query(sql, params, new CodeDefinitionRowMapper()); if (results != null && !results.isEmpty()) { return results.get(0); }/*from www. ja v a 2 s .co m*/ return null; }
From source file:com.eu.evaluation.server.dao.dictionary.ObjectDictionaryDAO.java
/** * ?/* w w w . ja v a 2 s .co m*/ */ public void invalidateAll() { String jpql = "update ObjectDictionary t set t.valid = :valid"; MapSqlParameterSource params = new MapSqlParameterSource("valid", false); this.createQuery(jpql, params).executeUpdate(); }
From source file:tds.assessment.repositories.impl.GradesQueryRepositoryImpl.java
@Override public List<String> findGrades(final String assessmentKey) { final SqlParameterSource parameters = new MapSqlParameterSource("key", assessmentKey); final String SQL = "SELECT \n" + " grade \n" + "FROM \n" + " setoftestgrades \n" + "WHERE \n" + " _fk_adminsubject = :key \n" + "ORDER BY \n" + " CAST(grade AS SIGNED)"; return jdbcTemplate.queryForList(SQL, parameters, String.class); }
From source file:tomekkup.helenos.dao.ClusterConfigDao.java
public ClusterConfiguration get(String alias) { return jdbcTemplate.queryForObject(queriesProperties.getProperty("clusterconfig.get.by.alias"), new MapSqlParameterSource("alias", alias), new ClusterConfigurationMapper()); }
From source file:org.string_db.jdbc.SpeciesRepositoryJdbc.java
@Override public List<Integer> loadCoreSpeciesIds() { return namedParameterJdbcTemplate.queryForList( "SELECT species_id from items.species where \"type\" = :type ;", new MapSqlParameterSource("type", "core"), Integer.class); }
From source file:tds.assessment.repositories.impl.FormQueryRepositoryImpl.java
@Override public List<Form> findFormsForAssessment(final String assessmentKey) { SqlParameterSource parameters = new MapSqlParameterSource("key", assessmentKey); final String formsSQL = "SELECT \n" + " segments._key AS segmentKey, \n" + " forms._key AS `key`, \n" + " forms.formid AS id, \n" + " forms.language, \n" + " forms.loadconfig AS loadVersion, \n" + " forms.updateconfig AS updateVersion, \n" + " forms.cohort \n" + "FROM \n" + " itembank.tblsetofadminsubjects segments \n" + "JOIN \n" + " itembank.testform forms \n" + " ON segments._key = forms._fk_adminsubject \n" + "WHERE \n" + " segments.virtualtest = :key \n" + " OR segments._key = :key"; return jdbcTemplate.query(formsSQL, parameters, (rs, row) -> new Form.Builder(rs.getString("key")).withSegmentKey(rs.getString("segmentKey")) .withId(rs.getString("id")).withLanguage(rs.getString("language")) .withCohort(rs.getString("cohort")) // calling getObject() and casting to Double because .getLong() defaults to 0 if null .withLoadVersion((Long) rs.getObject("loadVersion")) .withUpdateVersion((Long) rs.getObject("updateVersion")).build()); }
From source file:airport.database.dispatcher.airplane.FlyingMachineTypeDaoImpl.java
@Override public FlyingMachineType getFlyingMachineType(String typeMachine) { MapSqlParameterSource parameter = new MapSqlParameterSource("typeMachine", typeMachine); FlyingMachineType result;//from w w w . j a v a 2 s . c o m try { result = jdbcTemplate.queryForObject(SQL_QUERY_SELECT_ONE, parameter, new FlyingMachineTypeMapper()); } catch (EmptyResultDataAccessException e) { if (LOG.isInfoEnabled()) { LOG.info("Information on such type of the plane aren't present. Type plane : " + typeMachine); } return new FlyingMachineType(); } if (LOG.isInfoEnabled()) { LOG.info("Information on such type of the plane are present. Type plane : " + typeMachine + ". Result " + result); } return result; }
From source file:tds.assessment.repositories.impl.ItemGroupQueryRepositoryImpl.java
@Override public List<ItemGroup> findItemGroupsBySegment(final String segmentKey) { SqlParameterSource parameters = new MapSqlParameterSource("segmentKey", segmentKey); String SQL = "SELECT \n" + " groupID as itemGroup, \n" + " numItemsRequired as itemsRequired, \n" + " maxItems, \n" + " bpweight \n" + "FROM tbladminstimulus \n" + "WHERE _fk_AdminSubject = :segmentKey "; return jdbcTemplate.query(SQL, parameters, (rs, rowNum) -> new ItemGroup(rs.getString("itemGroup"), rs.getInt("itemsRequired"), rs.getInt("maxItems"), rs.getFloat("bpweight"))); }
From source file:com.eu.evaluation.server.dao.eva.EvaluateItemDAO.java
/** * ??//from w ww .java 2s . com * @param <T> * @param evaluateTypeEnum * @param entityEnum * @return */ public <T extends EvaluateItem> List<T> find(EvaluateTypeEnum evaluateTypeEnum, EntityEnum entityEnum) { String jpql = "select t from {0} t where t.objectDictionary.instanceType = :instanceType"; jpql = MessageFormat.format(jpql, evaluateTypeEnum.getEvaClass().getName()); MapSqlParameterSource params = new MapSqlParameterSource("instanceType", entityEnum.getInstanceType()); return this.createQuery(jpql, params).getResultList(); }
From source file:com.eu.evaluation.server.dao.eva.UpAndDownEvaluateItemDAO.java
public EvaluateItem findTheMatching(ObjectDictionary od, FieldDictionary fd, Map<String, Object> otherMap) { String jpql = "select t from UpAndDownEvlauateItem t where t.objectDictionary.id = :odID"; MapSqlParameterSource params = new MapSqlParameterSource("odID", od.getId()); String upEntityID = (String) otherMap.get(UpAndDownEvlauateItem.MAP_KEY_UP_ENTITY); if (upEntityID != null) { jpql += " and t.upEntity.id = :upID"; params.addValue("upID", upEntityID); }/*from w ww .j ava 2 s. c o m*/ String downEntityID = (String) otherMap.get(UpAndDownEvlauateItem.MAP_KEY_DOWN_ENTITY); if (downEntityID != null) { jpql += " and t.downEntity.id = :downID"; params.addValue("downID", downEntityID); } List<UpAndDownEvlauateItem> result = this.query(jpql, params); if (result.isEmpty()) { return null; } else if (result.size() == 1) { return result.get(0); } else { ObjectDictionary upEntity = getObjectDictionary(upEntityID); ObjectDictionary downEntity = getObjectDictionary(downEntityID); throw new RuntimeException("" + fd.getObjectDictionary().getDisplayname() + " ?=" + (upEntity == null ? "null" : upEntity.getDisplayname()) + " ; =" + (downEntity == null ? "null" : downEntity.getDisplayname())); } }