List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate
public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate)
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 2 s . c om*/ LefffDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public RowOfShapes loadRowOfShapes(int rowId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_ROW + " FROM ocr_row WHERE row_id=:row_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("row_id", rowId); LOG.debug(sql);/*from w w w. j a v a 2 s . c o m*/ logParameters(paramSource); RowOfShapes row = null; try { row = (RowOfShapes) jt.queryForObject(sql, paramSource, new RowOfShapesMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return row; }
From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java
@Override public Set<Term> getHeads(Term term) { MONITOR.startTask("getHeads"); try {//from w ww. ja v a 2s . c o m 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_heads ON term_id = termhead_head_id" + " WHERE termhead_term_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.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveSentence(SentenceInternal sentence) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("sentence_number", sentence.getSentenceNumber()); paramSource.addValue("sentence_file_id", sentence.getFileId() == 0 ? null : sentence.getFileId()); paramSource.addValue("sentence_text_id", sentence.getTextItemId() == 0 ? null : sentence.getTextItemId()); paramSource.addValue("sentence_id", sentence.getId()); paramSource.addValue("sentence_text", sentence.getText()); if (sentence.isNew()) { String sql = "INSERT INTO ftb_sentence (sentence_id, sentence_number, sentence_file_id, sentence_text_id, sentence_text) " + "VALUES (:sentence_id, :sentence_number, :sentence_file_id, :sentence_text_id, :sentence_text)"; LOG.info(sql);/*w w w .j av a 2 s .c o m*/ TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } else { String sql = "UPDATE ftb_sentence" + " SET sentence_number = :sentence_number" + ", sentence_file_id = :sentence_file_id" + ", sentence_text_id = :sentence_text_id" + ", sentence_text = :sentence_text" + " WHERE sentence_id = :sentence_id"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:org.surfnet.cruncher.repository.StatisticsRepositoryImpl.java
@Override public boolean uniqueUserLogonExists(String userId, Date loginDate, String spEntityId, String idpEntityId) { NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(cruncherJdbcTemplate); String query = "select count(*) from user_unique_logins_cache " + "where " + "userId=:userId AND " + "spEntityId=:spEntityId AND " + "idpEntityId=:idpEntityId AND " + "timespan=:timespan AND " + "month=:month AND " + "year=:year"; Calendar entryDate = new GregorianCalendar(); entryDate.setTime(loginDate);/*ww w . j a v a 2 s. com*/ int month = entryDate.get(MONTH) + 1; //this stupid thing is 0 based int year = entryDate.get(YEAR); Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("userId", userId); parameterMap.put("spEntityId", spEntityId); parameterMap.put("idpEntityId", idpEntityId); parameterMap.put("timespan", TimeSpan.MONTH.getCode()); parameterMap.put("month", month); parameterMap.put("year", year); return namedTemplate.queryForInt(query, parameterMap) > 0; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
public List<RowOfShapes> findRows(Paragraph paragraph) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_ROW + " FROM ocr_row WHERE row_paragraph_id=:row_paragraph_id" + " ORDER BY row_index"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("row_paragraph_id", paragraph.getId()); LOG.debug(sql);//w ww . j av a2s .c o m logParameters(paramSource); @SuppressWarnings("unchecked") List<RowOfShapes> rows = jt.query(sql, paramSource, new RowOfShapesMapper(this.getGraphicsServiceInternal())); return rows; }
From source file:com.joliciel.lefff.LefffDaoImpl.java
@Override public Lemma loadLemma(int lemmaId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_LEMMA + " FROM lef_lemma WHERE lemma_id=:lemma_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("lemma_id", lemmaId); LOG.info(sql);// ww w.j a va 2 s . co m 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.jochre.doc.DocumentDaoJdbc.java
@Override public void replaceAuthors(JochreDocument doc) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("docauthor_doc_id", doc.getId()); String sql = "DELETE FROM ocr_doc_author_map WHERE docauthor_doc_id = :docauthor_doc_id"; LOG.info(sql);//from w w w. jav a 2 s . c o m logParameters(paramSource); jt.update(sql, paramSource); for (Author author : doc.getAuthors()) { paramSource = new MapSqlParameterSource(); paramSource.addValue("docauthor_doc_id", doc.getId()); paramSource.addValue("docauthor_author_id", author.getId()); sql = "INSERT INTO ocr_doc_author_map (docauthor_doc_id, docauthor_author_id)" + " VALUES (:docauthor_doc_id, :docauthor_author_id)"; LOG.info(sql); logParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java
@Override public List<Context> getContexts(Term term) { MONITOR.startTask("getContexts"); try {//from ww w. j ava 2 s .c o m NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_CONTEXT + " FROM context" + " WHERE context_term_id = :context_term_id" + " ORDER BY context_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("context_term_id", ((PostGresTerm) term).getId()); LOG.trace(sql); LogParameters(paramSource); @SuppressWarnings("unchecked") List<Context> contexts = jt.query(sql, paramSource, new ContextMapper()); return contexts; } finally { MONITOR.endTask("getContexts"); } }
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);/*w w w.jav a 2 s . co m*/ LefffDaoImpl.LogParameters(paramSource); Lemma lemma = null; try { lemma = (Lemma) jt.queryForObject(sql, paramSource, new LemmaMapper(this.getLefffServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return lemma; }