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() 

Source Link

Document

Create an empty MapSqlParameterSource, with values to be added via addValue .

Usage

From source file:org.aksw.gerbil.database.ExperimentDAOImpl.java

@Override
public List<ExperimentTaskResult> getLatestResultsOfExperiments(String experimentType, String matching) {
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("experimentType", experimentType);
    parameters.addValue("matching", matching);
    parameters.addValue("unfinishedState", TASK_STARTED_BUT_NOT_FINISHED_YET);
    return this.template.query(GET_LATEST_EXPERIMENT_TASK_RESULTS, parameters,
            new ExperimentTaskResultRowMapper());
}

From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java

public List<JochreImage> findImages(ImageStatus[] imageStatuses) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_IMAGE + " FROM ocr_image WHERE image_imgstatus_id in (:image_imgstatus_id)"
            + " ORDER BY image_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    List<Integer> imageStatusList = new ArrayList<Integer>();
    for (ImageStatus imageStatus : imageStatuses)
        imageStatusList.add(imageStatus.getId());
    paramSource.addValue("image_imgstatus_id", imageStatusList);

    LOG.debug(sql);/*from w ww .  j a v a2 s  .co  m*/
    logParameters(paramSource);
    @SuppressWarnings("unchecked")
    List<JochreImage> images = jt.query(sql, paramSource,
            new JochreImageMapper(this.getGraphicsServiceInternal()));

    return images;
}

From source file:Implement.DAO.CommonDAOImpl.java

@Override
public AccountSession loginToYouTripperFacebook(String email) {
    simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("loginToYoutripperFacebook");
    SqlParameterSource in = new MapSqlParameterSource().addValue("username", email);
    Map<String, Object> record = simpleJdbcCall.execute(in);
    int id = (int) record.get("id");
    String name = (String) record.get("name");
    int type = (int) record.get("type");
    String image = (String) record.get("image");
    String token = (String) record.get("token");
    return new AccountSession(id, name, type, image, token);
}

From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java

public void savePhraseSubunit(PhraseSubunitInternal phraseSubunit) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("psubunit_punit_id",
            phraseSubunit.getPhraseUnit() == null ? null : phraseSubunit.getPhraseUnit().getId());
    paramSource.addValue("psubunit_word_id", phraseSubunit.getWordId() == 0 ? null : phraseSubunit.getWordId());
    paramSource.addValue("psubunit_position", phraseSubunit.getPosition());
    paramSource.addValue("psubunit_cat_id",
            phraseSubunit.getCategoryId() == 0 ? null : phraseSubunit.getCategoryId());
    paramSource.addValue("psubunit_subcat_id",
            phraseSubunit.getSubCategoryId() == 0 ? null : phraseSubunit.getSubCategoryId());
    paramSource.addValue("psubunit_morph_id",
            phraseSubunit.getMorphologyId() == 0 ? null : phraseSubunit.getMorphologyId());

    if (phraseSubunit.isNew()) {
        String sql = "SELECT nextval('ftb_phrase_subunit_psubunit_id_seq')";
        LOG.info(sql);//from  w  w w  . j a v a2  s . co m
        int phraseSubunitId = jt.queryForInt(sql, paramSource);
        paramSource.addValue("psubunit_id", phraseSubunitId);

        sql = "INSERT INTO ftb_phrase_subunit (psubunit_id, psubunit_punit_id, psubunit_word_id, psubunit_position"
                + ", psubunit_cat_id, psubunit_subcat_id, psubunit_morph_id) "
                + "VALUES (:psubunit_id, :psubunit_punit_id, :psubunit_word_id, :psubunit_position"
                + ", :psubunit_cat_id, :psubunit_subcat_id, :psubunit_morph_id)";

        LOG.info(sql);
        TreebankDaoImpl.LogParameters(paramSource);
        jt.update(sql, paramSource);

        phraseSubunit.setId(phraseSubunitId);
    } else {
        paramSource.addValue("psubunit_id", phraseSubunit.getId());
        String sql = "UPDATE ftb_phrase_subunit" + " SET psubunit_punit_id=:psubunit_punit_id"
                + ", psubunit_word_id=:psubunit_word_id" + ", psubunit_position=:psubunit_position"
                + ", psubunit_cat_id=:psubunit_cat_id" + ", psubunit_subcat_id=:psubunit_subcat_id"
                + ", psubunit_morph_id=:psubunit_morph_id " + " WHERE psubunit_id = :psubunit_id";

        LOG.info(sql);
        TreebankDaoImpl.LogParameters(paramSource);
        jt.update(sql, paramSource);
    }
}

From source file:com.joliciel.jochre.doc.DocumentDaoJdbc.java

@Override
public List<Author> findAuthors(JochreDocument jochreDocument) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_AUTHOR + " FROM ocr_author"
            + " INNER JOIN ocr_doc_author_map ON docauthor_author_id = author_id"
            + " WHERE docauthor_doc_id=:docauthor_doc_id" + " ORDER BY author_last_name, author_first_name";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("docauthor_doc_id", jochreDocument.getId());

    LOG.info(sql);/*from   w ww .ja  va  2s  .  com*/
    logParameters(paramSource);
    @SuppressWarnings("unchecked")
    List<Author> authors = jt.query(sql, paramSource, new AuthorMapper(this.getDocumentServiceInternal()));

    return authors;
}

From source file:com.joliciel.lefff.LefffDaoImpl.java

public Predicate loadPredicate(String predicateText) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PREDICATE + " FROM lef_predicate WHERE predicate_text=:predicate_text";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("predicate_text", predicateText);

    LOG.info(sql);// w  w w . j  a  v  a2 s . c o  m
    LefffDaoImpl.LogParameters(paramSource);
    Predicate predicate = null;
    try {
        predicate = (Predicate) jt.queryForObject(sql, paramSource,
                new PredicateMapper(this.getLefffServiceInternal()));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return predicate;
}

From source file:com.team3637.service.TagServiceMySQLImpl.java

@Override
public void delete(String name) {
    SqlParameterSource args = new MapSqlParameterSource().addValue("tagName", name);
    deleteTag.execute(args);/*from   ww w . j a v a 2s. c o  m*/
    String SQL = "DELETE FROM tags WHERE tag = ?";
    jdbcTemplateObject.update(SQL, name);
}

From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java

public RequestHeader loadRequestHeader(int id) throws DataAccessException {
    MapSqlParameterSource params = new MapSqlParameterSource();
    try {/*from w  w  w .  j a va 2s  . c  o m*/
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate());
        return template.queryForObject(SELECT_REQUEST, REQUEST_MAPPER, params);
    } catch (EmptyResultDataAccessException erdae) {
        return null;
    }
}

From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java

@Override
public Set<Term> getParents(final Term term) {
    MONITOR.startTask("getParents");
    try {/*  ww w  .  ja  v  a2s  . c  om*/
        NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
        String sql = "SELECT " + SELECT_TERM + " FROM term" + " INNER JOIN text ON term_text_id=text_id"
                + " INNER JOIN term_expansions ON term_id = termexp_term_id"
                + " WHERE termexp_expansion_id = :term_id" + " ORDER BY text_text";
        MapSqlParameterSource paramSource = new MapSqlParameterSource();
        paramSource.addValue("term_id", ((PostGresTerm) term).getId());

        LOG.trace(sql);
        LogParameters(paramSource);
        @SuppressWarnings("unchecked")
        List<Term> terms = jt.query(sql, paramSource, new TermMapper());

        Set<Term> termSet = new TreeSet<Term>(new TermFrequencyComparator());
        termSet.addAll(terms);
        return termSet;
    } finally {
        MONITOR.endTask("getHeads");
    }
}

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

/**
 * Add a BiologicalDataItem(only BED or GFF/GTF) as annotation for the genome
 * @param referenceId List of IDs of BiologicalDataItem instances
 * @param annotationFileId ID of BiologicalDataItem instance
 *//*from   w  w  w .  ja  v  a 2  s. co m*/
@Transactional(propagation = Propagation.MANDATORY)
public void addAnnotationFile(Long referenceId, Long annotationFileId) {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(GenomeParameters.REFERENCE_GENOME_ID.name(), referenceId);
    params.addValue(BiologicalDataItemDao.BiologicalDataItemParameters.BIO_DATA_ITEM_ID.name(),
            annotationFileId);
    getNamedParameterJdbcTemplate().update(addAnnotationDataItemByReferenceIdQuery, params);
}