List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:net.solarnetwork.node.dao.jdbc.JdbcSettingDao.java
@Override public String getSetting(String key, String type) { List<String> res = getJdbcTemplate().query(this.sqlGet, new RowMapper<String>() { @Override//from w ww .ja v a 2 s . c o m public String mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString(1); } }, key, type); if (res != null && res.size() > 0) { return res.get(0); } return null; }
From source file:at.ac.tuwien.qse.sepm.dao.impl.JDBCTagDAO.java
/** * Retrieve an existing Tag//from www. j av a 2 s . c om * * @param t Specifies which Tag to retrieve by providing the id. * @return the Tag-Objekt * @throws DAOException If the Tag can not be retrieved or the data store fails to select the record. */ public Tag read(Tag t) throws DAOException { logger.debug("reading Tag {}", t); try { return this.jdbcTemplate.queryForObject(readStatement, new Object[] { t.getId() }, new RowMapper<Tag>() { @Override public Tag mapRow(ResultSet rs, int rowNum) throws SQLException { Tag t = new Tag(); t.setId(rs.getInt(1)); t.setName(rs.getString(2)); return t; } }); } catch (DataAccessException e) { throw new DAOException("Failed to read a Tag", e); } }
From source file:com.sfs.whichdoctor.dao.DebitDAOImpl.java
/** * Used to get a DebitBean for a specified debitId and supplied load * options. A boolean parameter identifies whether to use the default reader * connection or optional writer connection datasource. * * @param debitId the debit id//from ww w. j a v a 2s .c om * @param loadDetails the load details * @param useWriterConn the use writer conn * * @return the debit bean * * @throws WhichDoctorDaoException the which doctor dao exception */ private DebitBean load(final int debitId, final BuilderBean loadDetails, final boolean useWriterConn) throws WhichDoctorDaoException { DebitBean debit = null; dataLogger.info("DebitId: " + debitId + " requested"); JdbcTemplate jdbcTemplate = this.getJdbcTemplateReader(); if (useWriterConn) { jdbcTemplate = this.getJdbcTemplateWriter(); } final String loadSQL = getSQL().getValue("debit/load") + " AND invoice.InvoiceId = ?"; try { debit = (DebitBean) jdbcTemplate.queryForObject(loadSQL, new Object[] { debitId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadDebit(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return debit; }
From source file:net.solarnetwork.node.dao.jdbc.general.JdbcGeneralLocationDatumDao.java
@Override @Transactional(readOnly = true, propagation = Propagation.REQUIRED) public List<GeneralLocationDatum> getDatumNotUploaded(String destination) { return findDatumNotUploaded(new RowMapper<GeneralLocationDatum>() { @Override/*from w ww. j a va2s.com*/ public GeneralLocationDatum mapRow(ResultSet rs, int rowNum) throws SQLException { if (log.isTraceEnabled()) { log.trace("Handling result row " + rowNum); } GeneralLocationDatum datum = new GeneralLocationDatum(); int col = 0; datum.setCreated(rs.getTimestamp(++col)); datum.setLocationId(rs.getLong(++col)); datum.setSourceId(rs.getString(++col)); String jdata = rs.getString(++col); if (jdata != null) { GeneralLocationDatumSamples s; try { s = objectMapper.readValue(jdata, GeneralLocationDatumSamples.class); datum.setSamples(s); } catch (IOException e) { log.error("Error deserializing JSON into GeneralLocationDatumSamples: {}", e.getMessage()); } } return datum; } }); }
From source file:org.onesun.atomator.dao.OAuthResultDAOImpl.java
@SuppressWarnings("unchecked") @Override/* w w w .j a v a 2 s . com*/ public OAuthResult get(String whereClause, Object[] object) { String query = "SELECT * FROM " + AUTH_ENTRY_TABLE + " " + whereClause; /** * Implement the RowMapper callback interface */ try { return (OAuthResult) Configuration.getJdbcTemplate().queryForObject(query, object, new RowMapper() { public Object mapRow(ResultSet resultSet, int rowNum) throws SQLException { return newPBEntry(resultSet); } }); } catch (EmptyResultDataAccessException e) { return null; } }
From source file:ru.org.linux.spring.SameIPController.java
private List<TopicItem> getTopics(String ip) { return jdbcTemplate.query( "SELECT sections.name as ptitle, groups.title as gtitle, topics.title as title, topics.id as msgid, postdate, deleted " + "FROM topics, groups, sections, users " + "WHERE topics.groupid=groups.id " + "AND sections.id=groups.section " + "AND users.id=topics.userid " + "AND topics.postip=?::inet " + "AND postdate>CURRENT_TIMESTAMP-'3 days'::interval ORDER BY msgid DESC", new RowMapper<TopicItem>() { @Override/*w ww. j av a 2 s.c om*/ public TopicItem mapRow(ResultSet rs, int rowNum) throws SQLException { return new TopicItem(rs, false); } }, ip); }
From source file:com.arcane.dao.Impl.PatternDaoImpl.java
public List<String> getPatternNames() { //return all pattern names LOG.info("Returning all pattern names"); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * from pattern"; List<String> patternNameList = jdbcTemplate.query(sql, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString("name"); }/*from www .ja v a 2 s. c om*/ }); return patternNameList; }
From source file:com.sfs.whichdoctor.dao.AddressVerificationDAOImpl.java
/** * Load the address verification beans associated with the supplied address guid. * * @param guid the guid/*from w w w .j av a 2 s. com*/ * @return the address verification bean * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<AddressVerificationBean> loadGUID(final int guid) throws WhichDoctorDaoException { Collection<AddressVerificationBean> addressVerifications = new ArrayList<AddressVerificationBean>(); String loadGUID = this.getSQL().getValue("addressVerification/loadGUID"); try { addressVerifications = this.getJdbcTemplateReader().query(loadGUID, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadAddressVerification(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug( "Could not find an address verification record for GUID (" + guid + "): " + ie.getMessage()); } return addressVerifications; }
From source file:eu.trentorise.smartcampus.resourceprovider.jdbc.JdbcServices.java
@Override public List<ResourceParameter> loadResourceParameterByUserId(String userId) { // Object[] parameters = new Object[] {userId}; // return queryForList(selectAppByUser,parameters,String.class); return query(selectAppByUser, new RowMapper<ResourceParameter>() { @Override/*from w w w . j a v a2s . c om*/ public ResourceParameter mapRow(ResultSet rs, int rownumber) throws SQLException { ResourceParameter e = new ResourceParameter(); e.setValue(rs.getString("value")); e.setClientId(rs.getString("clientId")); e.setParameter(rs.getString("parameter")); e.setServiceId(rs.getString("serviceId")); return e; } }, userId); }
From source file:com.krawler.spring.calendar.calendarmodule.JdbcCalendarUserDao.java
@Override public List<String> getCalendarIds(User user) { String query = "select cid from calendars where userid=?"; return queryJDBC(query, new Object[] { user.getUserID() }, new RowMapper<String>() { @Override/*from w w w . jav a2s . c om*/ public String mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString("cid"); } }); }