List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate update
@Override public int update(String sql, Map<String, ?> paramMap) throws DataAccessException
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);/* w w w . j a va2s. c o m*/ TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveTreebankFile(TreebankFileInternal treebankFile) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("file_name", treebankFile.getFileName()); if (treebankFile.isNew()) { String sql = "SELECT nextval('ftb_file_file_id_seq')"; LOG.info(sql);//from w ww . j av a 2 s . co m int fileId = jt.queryForInt(sql, paramSource); paramSource.addValue("file_id", fileId); sql = "INSERT INTO ftb_file (file_id, file_name) " + "VALUES (:file_id, :file_name)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); treebankFile.setId(fileId); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveWord(WordInternal word) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("word_text", word.getText()); paramSource.addValue("word_original_text", word.getOriginalText()); if (word.isNew()) { String sql = "SELECT nextval('ftb_word_word_id_seq')"; LOG.info(sql);//from w w w.j a va 2s. c o m int wordId = jt.queryForInt(sql, paramSource); paramSource.addValue("word_id", wordId); sql = "INSERT INTO ftb_word (word_id, word_text, word_original_text) VALUES (:word_id, :word_text, :word_original_text)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); word.setId(wordId); } else { String sql = "UPDATE ftb_word" + " SET word_text = :word_text" + ", word_original_text = :word_original_text" + " WHERE word_id = :word_id"; paramSource.addValue("word_id", word.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveCategory(CategoryInternal category) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("cat_code", category.getCode()); paramSource.addValue("cat_description", category.getDescription()); if (category.isNew()) { String sql = "SELECT nextval('ftb_category_cat_id_seq')"; LOG.info(sql);// w ww . j a va2s . c o m int categoryId = jt.queryForInt(sql, paramSource); paramSource.addValue("cat_id", categoryId); sql = "INSERT INTO ftb_category (cat_id, cat_code, cat_description) VALUES (:cat_id, :cat_code, :cat_description)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); category.setId(categoryId); } else { String sql = "UPDATE ftb_category" + " SET cat_code = :cat_code" + ", cat_description = :cat_description" + " WHERE cat_id = :cat_id"; paramSource.addValue("cat_id", category.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
@Override public void saveTextItem(TextItemInternal textItem) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("text_file_id", textItem.getFileId()); paramSource.addValue("text_external_id", textItem.getExternalId()); if (textItem.isNew()) { String sql = "SELECT nextval('ftb_text_text_id_seq')"; LOG.info(sql);//from w w w .j av a 2 s. c o m int textItemId = jt.queryForInt(sql, paramSource); paramSource.addValue("text_id", textItemId); sql = "INSERT INTO ftb_text (text_id, text_file_id, text_external_id) VALUES (:text_id, :text_file_id, :text_external_id)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); textItem.setId(textItemId); } else { String sql = "UPDATE ftb_text" + " SET text_file_id = :text_file_id" + ", text_external_id = :text_external_id" + " WHERE text_id = :text_id"; paramSource.addValue("text_id", textItem.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveMorphology(MorphologyInternal morphology) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("morph_code", morphology.getCode()); paramSource.addValue("morph_description", morphology.getDescription()); if (morphology.isNew()) { String sql = "SELECT nextval('ftb_morph_morph_id_seq')"; LOG.info(sql);//w w w . j a va 2 s. c o m int morphologyId = jt.queryForInt(sql, paramSource); paramSource.addValue("morph_id", morphologyId); sql = "INSERT INTO ftb_morph (morph_id, morph_code, morph_description) VALUES (:morph_id, :morph_code, :morph_description)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); morphology.setId(morphologyId); } else { String sql = "UPDATE ftb_morph" + " SET morph_code = :morph_code" + ", morph_description = :morph_description" + " WHERE morph_id = :morph_id"; paramSource.addValue("morph_id", morphology.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void savePhraseType(PhraseTypeInternal phraseType) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("ptype_code", phraseType.getCode()); paramSource.addValue("ptype_description", phraseType.getDescription()); if (phraseType.isNew()) { String sql = "SELECT nextval('ftb_phrase_type_ptype_id_seq')"; LOG.info(sql);/* www . j a v a2 s . c o m*/ int phraseTypeId = jt.queryForInt(sql, paramSource); paramSource.addValue("ptype_id", phraseTypeId); sql = "INSERT INTO ftb_phrase_type (ptype_id, ptype_code, ptype_description) VALUES (:ptype_id, :ptype_code, :ptype_description)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); phraseType.setId(phraseTypeId); } else { String sql = "UPDATE ftb_phrase_type" + " SET ptype_code = :ptype_code" + ", ptype_description = :ptype_description" + " WHERE ptype_id = :ptype_id"; paramSource.addValue("ptype_id", phraseType.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveFunction(FunctionInternal function) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("function_code", function.getCode()); paramSource.addValue("function_description", function.getDescription()); if (function.isNew()) { String sql = "SELECT nextval('ftb_function_function_id_seq')"; LOG.info(sql);//from w ww . j av a 2 s. c om int functionId = jt.queryForInt(sql, paramSource); paramSource.addValue("function_id", functionId); sql = "INSERT INTO ftb_function (function_id, function_code, function_description) VALUES (:function_id, :function_code, :function_description)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); function.setId(functionId); } else { String sql = "UPDATE ftb_function" + " SET function_code = :function_code" + ", function_description = :function_description" + " WHERE function_id = :function_id"; paramSource.addValue("function_id", function.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
From source file:com.joliciel.frenchTreebank.TreebankDaoImpl.java
public void saveSubCategory(SubCategoryInternal subCategory) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("subcat_code", subCategory.getCode()); paramSource.addValue("subcat_cat_id", subCategory.getCategoryId()); paramSource.addValue("subcat_description", subCategory.getDescription()); if (subCategory.isNew()) { String sql = "SELECT nextval('ftb_sub_category_subcat_id_seq')"; LOG.info(sql);/*w ww.j a v a 2s . co m*/ int subCategoryId = jt.queryForInt(sql, paramSource); paramSource.addValue("subcat_id", subCategoryId); sql = "INSERT INTO ftb_sub_category (subcat_id, subcat_code, subcat_cat_id, subcat_description) VALUES (:subcat_id, :subcat_code, :subcat_cat_id, :subcat_description)"; LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); subCategory.setId(subCategoryId); } else { String sql = "UPDATE ftb_sub_subCategory" + " SET subcat_code = :subcat_code" + ", subcat_cat_id = :subcat_cat_id" + ", subcat_description = :subcat_description" + " WHERE subcat_id = :subcat_id"; paramSource.addValue("subcat_id", subCategory.getId()); LOG.info(sql); TreebankDaoImpl.LogParameters(paramSource); jt.update(sql, paramSource); } }
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);/* ww 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); } }