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

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

Introduction

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

Prototype

@Override
    @Nullable
    public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
            throws DataAccessException 

Source Link

Usage

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

@Override
public Lemma loadLemma(String text, int index, String complement) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_LEMMA + " FROM lef_lemma" + " WHERE lemma_text=:lemma_text"
            + " AND lemma_index=:lemma_index" + " AND lemma_complement=:lemma_complement";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("lemma_text", text);
    paramSource.addValue("lemma_index", index);
    paramSource.addValue("lemma_complement", complement);

    LOG.info(sql);//from  www.  j  a  v a2  s  .  com
    LefffDaoImpl.LogParameters(paramSource);
    Lemma lemma = null;
    try {
        lemma = (Lemma) jt.queryForObject(sql, paramSource, new LemmaMapper(this.getLefffServiceInternal()));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return lemma;
}

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);//ww  w.  jav  a2s .  c om
    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

@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   ww  w. j ava  2s .  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;
}

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

public Category loadCategory(int categoryId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_CATEGORY + " FROM ftb_category WHERE cat_id=:cat_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("cat_id", categoryId);

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

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

@Override
public TextItem loadTextItem(int textItemId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_TEXT_ITEM + " FROM ftb_text WHERE text_id=:text_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("text_id", textItemId);

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

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

public Category loadCategory(String categoryCode) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_CATEGORY + " FROM ftb_category WHERE cat_code=:cat_code";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("cat_code", categoryCode);

    LOG.info(sql);//ww  w . j  a v  a  2 s .  com
    TreebankDaoImpl.LogParameters(paramSource);
    Category category = null;
    try {
        category = (Category) jt.queryForObject(sql, paramSource, new CategoryMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return category;
}

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

public Morphology loadMorphology(int morphologyId) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_MORPHOLOGY + " FROM ftb_morph WHERE morph_id=:morph_id";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("morph_id", morphologyId);

    LOG.info(sql);//from   w w  w .  ja v  a  2s . com
    TreebankDaoImpl.LogParameters(paramSource);
    Morphology morphology = null;
    try {
        morphology = (Morphology) jt.queryForObject(sql, paramSource, new MorphologyMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return morphology;
}

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 w w . ja v  a2 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 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 www  .j a  v a2s .  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 Function loadFunction(String functionCode) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_FUNCTION + " FROM ftb_function WHERE function_code=:function_code";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("function_code", functionCode);

    LOG.info(sql);/*  w w w .  ja va  2 s . c om*/
    TreebankDaoImpl.LogParameters(paramSource);
    Function function = null;
    try {
        function = (Function) jt.queryForObject(sql, paramSource, new FunctionMapper());
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return function;
}