List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate
public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate)
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void savePhraseDescendantMapping(Phrase parent, Phrase descendant) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("pchild_phrase_id", parent.getId()); paramSource.addValue("pchild_child_id", descendant.getId()); String sql = "INSERT INTO ftb_phrase_child (pchild_phrase_id, pchild_child_id) VALUES (:pchild_phrase_id, :pchild_child_id)"; LOG.info(sql);//from www . ja va 2 s. co m TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); }
From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java
public Term loadTerm(int termId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_TERM + " FROM term" + " INNER JOIN text ON term_text_id=text_id" + " WHERE term_id=:term_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("term_id", termId); LOG.trace(sql);/* www .j a va 2 s.c o m*/ LogParameters(paramSource); Term term = null; try { term = (Term) jt.queryForObject(sql, paramSource, new TermMapper()); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return term; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public GroupOfShapes loadGroupOfShapes(int groupId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_GROUP + " FROM ocr_group WHERE group_id=:group_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("group_id", groupId); LOG.debug(sql);// ww w. j a va 2 s . c om logParameters(paramSource); GroupOfShapes group = null; try { group = (GroupOfShapes) jt.queryForObject(sql, paramSource, new GroupOfShapesMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return group; }
From source file:com.joliciel.lefff.LefffDaoImpl.java
@Override public void saveLemma(LemmaInternal lemma) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("lemma_text", lemma.getText()); paramSource.addValue("lemma_index", lemma.getIndex()); paramSource.addValue("lemma_complement", lemma.getComplement()); if (lemma.isNew()) { String sql = "SELECT nextval('seq_lemma_id')"; LOG.info(sql);/*from w w w. j a v a 2 s .c o m*/ int lemmaId = jt.queryForInt(sql, paramSource); paramSource.addValue("lemma_id", lemmaId); sql = "INSERT INTO lef_lemma (lemma_id, lemma_text, lemma_index, lemma_complement)" + " VALUES (:lemma_id, :lemma_text, :lemma_index, :lemma_complement)"; LOG.info(sql); LefffDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); lemma.setId(lemmaId); } else { String sql = "UPDATE lef_lemma" + " SET lemma_text = :lemma_text" + ", lemma_index = :lemma_index" + ", lemma_complement = :lemma_complement" + " WHERE lemma_id = :lemma_id"; paramSource.addValue("lemma_id", lemma.getId()); LOG.info(sql); LefffDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java
public Term loadTerm(String termText) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_TERM + " FROM term" + " INNER JOIN text ON term_text_id=text_id" + " WHERE text_text=:term_text" + " AND term_project_id=:term_project_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("term_text", termText); paramSource.addValue("term_project_id", this.getCurrentProjectId()); LOG.trace(sql);// w w w . j a va 2 s . co m LogParameters(paramSource); Term term = null; try { term = (Term) jt.queryForObject(sql, paramSource, new TermMapper()); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return term; }
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 ww .j a v a 2 s.com*/ TreebankDaoImpl.LogParameters(paramSource); Function function = null; try { function = (Function) jt.queryForObject(sql, paramSource, new FunctionMapper()); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return function; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<GroupOfShapes> findGroups(RowOfShapes row) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_GROUP + " FROM ocr_group WHERE group_row_id=:group_row_id" + " ORDER BY group_index"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("group_row_id", row.getId()); LOG.debug(sql);// w w w .j a v a2 s. co m logParameters(paramSource); @SuppressWarnings("unchecked") List<GroupOfShapes> groups = jt.query(sql, paramSource, new GroupOfShapesMapper(this.getGraphicsServiceInternal())); return groups; }
From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java
public void saveTerm(PostGresTerm term) { if (term.isDirty()) { int textId = this.getTextId(term.getText()); term.setTextId(textId);// w w w.j av a2 s . c om NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("term_text_id", term.getTextId()); paramSource.addValue("term_frequency", term.getFrequency()); paramSource.addValue("term_project_id", this.getCurrentProjectId()); paramSource.addValue("term_marked", term.isMarked()); paramSource.addValue("term_expansion_count", term.getExpansionCount()); paramSource.addValue("term_head_count", term.getHeadCount()); if (term.isNew()) { String sql = "SELECT nextval('seq_term_id')"; LOG.trace(sql); int termId = jt.queryForInt(sql, paramSource); paramSource.addValue("term_id", termId); sql = "INSERT INTO term (term_id, term_text_id, term_project_id, term_frequency, term_marked, term_expansion_count, term_head_count)" + " VALUES (:term_id, :term_text_id, :term_project_id, :term_frequency, :term_marked, :term_expansion_count, :term_head_count)"; LOG.trace(sql); LogParameters(paramSource); jt.update(sql, paramSource); term.setId(termId); } else { String sql = "UPDATE term" + " SET term_text_id = :term_text_id" + ", term_frequency = :term_frequency" + ", term_project_id = :term_project_id" + ", term_marked = :term_marked" + ", term_expansion_count = :term_expansion_count" + ", term_head_count = :term_head_count" + " WHERE term_id = :term_id"; paramSource.addValue("term_id", term.getId()); LOG.trace(sql); LogParameters(paramSource); jt.update(sql, paramSource); } term.setDirty(false); } }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<GroupOfShapes> findGroupsForMerge() { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_GROUP + " FROM ocr_group WHERE group_id IN" + " (SELECT shape_group_id FROM ocr_shape WHERE shape_letter LIKE '%|%')" + " ORDER BY group_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); LOG.debug(sql);/*from w ww .j av a 2 s. c o m*/ logParameters(paramSource); @SuppressWarnings("unchecked") List<GroupOfShapes> groups = jt.query(sql, paramSource, new GroupOfShapesMapper(this.getGraphicsServiceInternal())); return groups; }
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);// w w w . j a v a 2 s. com LefffDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); }