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

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

Introduction

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

Prototype

public MapSqlParameterSource(String paramName, @Nullable Object value) 

Source Link

Document

Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.

Usage

From source file:com.epam.catgenome.dao.reference.ReferenceGenomeDao.java

/**
 * Loads a List of annotation files from the database by genome IDs
 * @param referenceId ID for the genome/*w w w. j a  v a  2s.  c  om*/
 * @return List of BiologicalDataItem, matching specified IDs
 */
@Transactional(propagation = Propagation.MANDATORY)
public List<Long> loadAnnotationFileIdsByReferenceId(Long referenceId) {
    return getNamedParameterJdbcTemplate().query(loadAnnotationDataIdsByReferenceIdQuery,
            new MapSqlParameterSource(GenomeParameters.REFERENCE_GENOME_ID.name(), referenceId),
            GenomeParameters.ID_MAPPER);
}

From source file:tds.assessment.repositories.impl.AccommodationsQueryRepositoryImpl.java

@Override
public List<AccommodationDependency> findAssessmentAccommodationDependencies(final String clientName,
        final String assessmentId) {
    SqlParameterSource parameters = new MapSqlParameterSource("assessmentId", assessmentId)
            .addValue("clientName", clientName);

    final String SQL = "SELECT \n" + "   iftype, \n" + "   ifvalue, \n" + "   thentype, \n" + "   thenvalue, \n"
            + "   isdefault \n" + "FROM \n" + "   configs.client_tooldependencies \n" + "WHERE \n"
            + "   clientname = :clientName AND \n" + "   context = :assessmentId \n";

    return jdbcTemplate.query(SQL, parameters,
            (rs, row) -> new AccommodationDependency.Builder(assessmentId).withIfType(rs.getString("iftype"))
                    .withIfValue(rs.getString("ifvalue")).withThenType(rs.getString("thentype"))
                    .withThenValue(rs.getString("thenvalue")).withIsDefault(rs.getBoolean("isdefault"))
                    .build());//w w  w . jav  a2 s.  c  o  m
}