Example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate update

List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate update

Introduction

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

Prototype

@Override
    public int update(String sql, Map<String, ?> paramMap) throws DataAccessException 

Source Link

Usage

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

public void deleteLemma(int lemmaId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    String sql = "DELETE FROM lef_lemma WHERE lemma_id = :lemma_id";
    paramSource.addValue("lemma_id", lemmaId);
    LOG.info(sql);//from  w  w  w .  ja  v a  2  s  .  c  o  m
    LefffDaoImpl.LogParameters(paramSource);
    jt.update(sql, paramSource);
}

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

public void deleteCategory(int categoryId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    String sql = "DELETE FROM lef_category WHERE category_id = :category_id";
    paramSource.addValue("category_id", categoryId);
    LOG.info(sql);/*  www. java 2  s  .  c  o m*/
    LefffDaoImpl.LogParameters(paramSource);
    jt.update(sql, paramSource);
}

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

public void deleteAttribute(int attributeId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    String sql = "DELETE FROM lef_attribute WHERE attribute_id = :attribute_id";
    paramSource.addValue("attribute_id", attributeId);
    LOG.info(sql);/*from ww  w .  ja  v  a 2s . c o m*/
    LefffDaoImpl.LogParameters(paramSource);
    jt.update(sql, paramSource);
}

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

public void deletePredicate(int predicateId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    String sql = "DELETE FROM lef_predicate WHERE predicate_id = :predicate_id";
    paramSource.addValue("predicate_id", predicateId);
    LOG.info(sql);/*from   w w  w. j  a v  a 2s .  c  o m*/
    LefffDaoImpl.LogParameters(paramSource);
    jt.update(sql, paramSource);
}

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

@Override
public void saveAttributes(LefffEntryInternal entry) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("entatt_entry_id", entry.getId());

    String sql = "DELETE FROM lef_entry_attribute WHERE entatt_entry_id = :entatt_entry_id";

    LOG.info(sql);/*w  ww  . ja v  a 2 s  . com*/
    LefffDaoImpl.LogParameters(paramSource);
    jt.update(sql, paramSource);

    for (Attribute attribute : entry.getAttributes()) {
        paramSource = new MapSqlParameterSource();
        paramSource.addValue("entatt_entry_id", entry.getId());
        paramSource.addValue("entatt_attribute_id", attribute.getId());

        sql = "INSERT INTO lef_entry_attribute (entatt_entry_id, entatt_attribute_id)"
                + " VALUES (:entatt_entry_id, :entatt_attribute_id)";

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

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

@Override
public void deleteContiguousShapeInternal(ShapeInternal shape) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("shape_id", shape.getId());

    String sql = "DELETE FROM ocr_shape WHERE shape_id = :shape_id";
    LOG.debug(sql);/*from   w w  w .  j ava 2s.  c om*/
    logParameters(paramSource);
    jt.update(sql, paramSource);
}

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

@Override
public void saveJochrePage(JochrePage jochrePage) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    JochrePageInternal iJochrePage = (JochrePageInternal) jochrePage;

    paramSource.addValue("page_doc_id", jochrePage.getDocumentId());
    paramSource.addValue("page_index", jochrePage.getIndex());
    String sql = null;//from  ww  w . j  a  v  a  2s.c om

    if (jochrePage.isNew()) {
        sql = "SELECT nextval('ocr_page_id_seq')";
        LOG.info(sql);
        int jochrePageId = jt.queryForInt(sql, paramSource);
        paramSource.addValue("page_id", jochrePageId);

        sql = "INSERT INTO ocr_page (page_id, page_doc_id, page_index) "
                + "VALUES (:page_id, :page_doc_id, :page_index)";

        LOG.info(sql);
        logParameters(paramSource);
        jt.update(sql, paramSource);

        iJochrePage.setId(jochrePageId);
    } else {
        paramSource.addValue("page_id", jochrePage.getId());

        sql = "UPDATE ocr_page" + " SET page_doc_id = :page_doc_id" + ", page_index = :page_index"
                + " WHERE page_id = :page_id";

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

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

void saveHeads(Term term) {
    PostGresTerm iTerm = (PostGresTerm) term;
    for (Term head : iTerm.getHeadSet().getItemsAdded()) {
        NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
        String sql = "INSERT INTO term_heads (termhead_term_id, termhead_head_id)"
                + " VALUES (:termhead_term_id, :termhead_head_id)";
        MapSqlParameterSource paramSource = new MapSqlParameterSource();
        paramSource.addValue("termhead_head_id", ((PostGresTerm) head).getId());
        paramSource.addValue("termhead_term_id", iTerm.getId());

        LOG.trace(sql);/*w w w  .j  a v a2  s  . c o  m*/
        LogParameters(paramSource);
        jt.update(sql, paramSource);
    }
    iTerm.getHeadSet().cleanSlate();
}

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

void saveExpansions(Term term) {
    PostGresTerm iTerm = (PostGresTerm) term;
    for (Term expansion : iTerm.getExpansionSet().getItemsAdded()) {
        NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
        String sql = "INSERT INTO term_expansions (termexp_term_id, termexp_expansion_id)"
                + " VALUES (:termexp_term_id, :termexp_expansion_id)";
        MapSqlParameterSource paramSource = new MapSqlParameterSource();
        paramSource.addValue("termexp_term_id", iTerm.getId());
        paramSource.addValue("termexp_expansion_id", ((PostGresTerm) expansion).getId());

        LOG.trace(sql);//from  w  w  w . j a  va  2  s . co  m
        LogParameters(paramSource);
        jt.update(sql, paramSource);
    }
    iTerm.getExpansionSet().cleanSlate();
}

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

public void saveWord(WordInternal word) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("word_text", word.getText());
    if (word.isNew()) {
        String sql = "SELECT nextval('seq_word_id')";
        LOG.info(sql);/*w w  w . ja  v a 2  s.c o  m*/
        int wordId = jt.queryForInt(sql, paramSource);
        paramSource.addValue("word_id", wordId);

        sql = "INSERT INTO lef_word (word_id, word_text) VALUES (:word_id, :word_text)";

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

        word.setId(wordId);
    } else {
        String sql = "UPDATE lef_word" + " SET word_text = :word_text" + " WHERE word_id = :word_id";

        paramSource.addValue("word_id", word.getId());
        LOG.info(sql);
        LefffDaoImpl.LogParameters(paramSource);
        jt.update(sql, paramSource);
    }
}