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

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

Introduction

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

Prototype

public MapSqlParameterSource addValue(String paramName, @Nullable Object value) 

Source Link

Document

Add a parameter to this parameter source.

Usage

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

public PhraseType loadPhraseType(String phraseTypeCode) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PHRASE_TYPE + " FROM ftb_phrase_type WHERE ptype_code=:ptype_code";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("ptype_code", phraseTypeCode);

    LOG.info(sql);//ww  w.  j a v a  2 s  .  c o m
    TreebankDaoImpl.LogParameters(paramSource);
    PhraseType phraseType = null;
    try {
        phraseType = (PhraseType) jt.queryForObject(sql, paramSource, new PhraseTypeMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return phraseType;
}

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

public PhraseType loadPhraseType(int phraseTypeId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PHRASE_TYPE + " FROM ftb_phrase_type WHERE ptype_id=:ptype_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("ptype_id", phraseTypeId);

    LOG.info(sql);//from  w w  w.  j  a  v a2  s  .co m
    TreebankDaoImpl.LogParameters(paramSource);
    PhraseType phraseType = null;
    try {
        phraseType = (PhraseType) jt.queryForObject(sql, paramSource, new PhraseTypeMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return phraseType;
}

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

public SubCategory loadSubCategory(int subCategoryId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_SUB_CATEGORY + " FROM ftb_sub_category WHERE subcat_id = :subcat_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("subcat_id", subCategoryId);

    LOG.info(sql);/*from   w  w w . j a v  a  2 s  .c  o m*/
    TreebankDaoImpl.LogParameters(paramSource);
    SubCategory subCategory = null;
    try {
        subCategory = (SubCategory) jt.queryForObject(sql, paramSource, new SubCategoryMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return subCategory;
}

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

public Word loadWord(int wordId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_WORD + " FROM ftb_word WHERE word_id=:word_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("word_id", wordId);

    LOG.info(sql);/*from  ww  w . ja  va  2  s .  c  o  m*/
    TreebankDaoImpl.LogParameters(paramSource);
    Word word = null;
    try {
        word = (Word) jt.queryForObject(sql, paramSource, new WordMapper(this.treebankServiceInternal));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return word;
}

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

@SuppressWarnings("unchecked")
@Override/*from   ww w . ja v a 2s . c o  m*/
public List<PhraseSubunit> findPhraseSubunits(PhraseUnit phraseUnit) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PHRASE_SUBUNIT + " FROM ftb_phrase_subunit"
            + " WHERE psubunit_punit_id = :psubunit_punit_id" + " ORDER BY psubunit_position";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("psubunit_punit_id", phraseUnit.getId());

    LOG.info(sql);
    TreebankDaoImpl.LogParameters(paramSource);
    List<PhraseSubunit> phraseSubunits = jt.query(sql, paramSource,
            new PhraseSubUnitMapper(this.treebankServiceInternal));

    return phraseSubunits;
}

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

public List<Integer> findSentenceIds(TreebankFile treebankFile) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT sentence_id" + " FROM ftb_sentence" + " WHERE sentence_file_id=:sentence_file_id"
            + " ORDER BY sentence_id";

    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("sentence_file_id", treebankFile.getId());

    LOG.info(sql);/*www .j av  a 2s .co m*/
    TreebankDaoImpl.LogParameters(paramSource);

    @SuppressWarnings("unchecked")
    List<Integer> sentenceIds = jt.queryForList(sql, paramSource, Integer.class);

    return sentenceIds;
}

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

public PhraseUnit loadPhraseUnit(int phraseUnitId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PHRASE_UNIT + " FROM ftb_phrase_unit WHERE punit_id=:punit_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("punit_id", phraseUnitId);

    LOG.info(sql);//from   w  w  w. j a  v a  2s .c  om
    TreebankDaoImpl.LogParameters(paramSource);
    PhraseUnit phraseUnit = null;
    try {
        phraseUnit = (PhraseUnit) jt.queryForObject(sql, paramSource,
                new PhraseUnitMapper(this.treebankServiceInternal));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return phraseUnit;
}

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

public TreebankFile loadTreebankFile(String fileName) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_TREEBANK_FILE + " FROM ftb_file WHERE file_name=:file_name";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("file_name", fileName);

    LOG.info(sql);//from  w w w  . j a  v  a 2 s . c om
    TreebankDaoImpl.LogParameters(paramSource);
    TreebankFile treebankFile = null;
    try {
        treebankFile = (TreebankFile) jt.queryForObject(sql, paramSource,
                new TreebankFileMapper(treebankServiceInternal));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return treebankFile;
}

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

public TreebankFile loadTreebankFile(int fileId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_TREEBANK_FILE + " FROM ftb_file WHERE file_id=:file_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("file_id", fileId);

    LOG.info(sql);//from  w  ww .ja v  a 2  s. c om
    TreebankDaoImpl.LogParameters(paramSource);
    TreebankFile treebankFile = null;
    try {
        treebankFile = (TreebankFile) jt.queryForObject(sql, paramSource,
                new TreebankFileMapper(treebankServiceInternal));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return treebankFile;
}

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

@Override
public Phrase loadPhrase(int phraseId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_PHRASE + " FROM ftb_phrase WHERE phrase_id=:phrase_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("phrase_id", phraseId);

    LOG.info(sql);//from  w w w . j a v a 2 s .c  o m
    TreebankDaoImpl.LogParameters(paramSource);
    Phrase phrase = null;
    try {
        phrase = (Phrase) jt.queryForObject(sql, paramSource, new PhraseMapper(this.treebankServiceInternal));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return phrase;
}