List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate queryForObject
@Override @Nullable public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType) throws DataAccessException
From source file:com.joliciel.lefff.LefffDaoImpl.java
public Predicate loadPredicate(int predicateId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_PREDICATE + " FROM lef_predicate WHERE predicate_id=:predicate_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("predicate_id", predicateId); LOG.info(sql);/*from w w w . j a v a 2 s . c om*/ LefffDaoImpl.LogParameters(paramSource); Predicate predicate = null; try { predicate = (Predicate) jt.queryForObject(sql, paramSource, new PredicateMapper(this.getLefffServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return predicate; }
From source file:com.joliciel.lefff.LefffDaoImpl.java
public Word loadWord(String text) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); MapSqlParameterSource paramSource = new MapSqlParameterSource(); if (text == null) text = ""; String sql = "SELECT " + SELECT_WORD + " FROM lef_word WHERE word_text=:word_text"; paramSource.addValue("word_text", text); LOG.info(sql);/*from w w w . ja v a 2 s .com*/ LefffDaoImpl.LogParameters(paramSource); Word word = null; try { word = (Word) jt.queryForObject(sql, paramSource, new WordMapper(this.lefffServiceInternal)); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return word; }
From source file:com.joliciel.lefff.LefffDaoImpl.java
public Predicate loadPredicate(String predicateText) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_PREDICATE + " FROM lef_predicate WHERE predicate_text=:predicate_text"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("predicate_text", predicateText); LOG.info(sql);//www. j a v a2s . c o m LefffDaoImpl.LogParameters(paramSource); Predicate predicate = null; try { predicate = (Predicate) jt.queryForObject(sql, paramSource, new PredicateMapper(this.getLefffServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return predicate; }
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);/* w w w .j a v a 2s. 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.jochre.graphics.GraphicsDaoJdbc.java
@Override public Shape loadShape(int shapeId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_SHAPE + " FROM ocr_shape WHERE shape_id=:shape_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("shape_id", shapeId); LOG.debug(sql);/*from w w w. jav a 2s. c o m*/ logParameters(paramSource); Shape shape = null; try { shape = (Shape) jt.queryForObject(sql, paramSource, new ShapeMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return shape; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public JochreImage loadJochreImage(int imageId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_IMAGE + " FROM ocr_image WHERE image_id=:image_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("image_id", imageId); LOG.debug(sql);/*w w w .j ava2 s . c om*/ logParameters(paramSource); JochreImage image = null; try { image = (JochreImage) jt.queryForObject(sql, paramSource, new JochreImageMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return image; }
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);// w w w . j a v a 2 s . c o m 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.jochre.graphics.GraphicsDaoJdbc.java
@Override public Paragraph loadParagraph(int paragraphId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_PARAGRAPH + " FROM ocr_paragraph WHERE paragraph_id=:paragraph_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("paragraph_id", paragraphId); LOG.debug(sql);//from w w w. j av a2 s .c o m logParameters(paramSource); Paragraph paragraph = null; try { paragraph = (Paragraph) jt.queryForObject(sql, paramSource, new ParagraphMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return paragraph; }
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 va2s . 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.lefff.LefffDaoImpl.java
public Attribute loadAttribute(String attributeCode, String attributeValue) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_ATTRIBUTE + " FROM lef_attribute" + " WHERE attribute_code=:attribute_code" + " AND attribute_value=:attribute_value"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("attribute_code", attributeCode); paramSource.addValue("attribute_value", attributeValue); LOG.info(sql);//from w ww.j ava 2s. com LefffDaoImpl.LogParameters(paramSource); Attribute attribute = null; try { attribute = (Attribute) jt.queryForObject(sql, paramSource, new AttributeMapper(this.getLefffServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return attribute; }