List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:org.smigo.message.JdbcMessageDao.java
@Override public List<Message> getMessage(Locale locale, int from, int size) { final String whereParameter = locale.getLanguage() + "%"; return jdbcTemplate.query(SELECT, new Object[] { whereParameter, from, size }, new RowMapper<Message>() { @Override/* w w w . j av a 2s . c o m*/ public Message mapRow(ResultSet rs, int rowNum) throws SQLException { return new Message(rs.getInt("id"), rs.getString("text"), rs.getString("username"), rs.getDate("createdate")); } }); }
From source file:com.sfs.whichdoctor.dao.WhichDoctorFinancialObjectDAOImpl.java
/** * Check number.// w w w. j av a2 s .c o m * * @param type the type * @param existingNumber the existing number * @param issuedDate the issued date * @return the string */ protected String checkNumber(final String type, final String existingNumber, final Date issuedDate) { String number = ""; /* Does a receipt number need to be generated */ Date issued = Calendar.getInstance().getTime(); if (issuedDate != null) { issued = issuedDate; } boolean generateNumber = true; if (existingNumber != null) { if (existingNumber.compareTo("") != 0) { generateNumber = false; } } if (generateNumber) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy"); int intNumber = 0; String strNumber = ""; try { strNumber = (String) this.getJdbcTemplateReader().queryForObject( this.getSQL().getValue(type + "/findMaxNumber"), new Object[] { simpleDateFormat.format(issued) + "%" }, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString(1); } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search } if (strNumber != null) { strNumber = strNumber.substring(2); intNumber = Integer.parseInt(strNumber); } else { intNumber = 0; } strNumber = String.valueOf(intNumber + 1); while (strNumber.length() < 4) { strNumber = "0" + strNumber; } number = simpleDateFormat.format(issued) + strNumber; } else { number = existingNumber; } return number; }
From source file:nl.surfnet.coin.shared.log.ApiCallLogServiceImpl.java
@Override public List<ApiCallLog> findApiCallLog(String serviceProvider) { return jdbcTemplate.query( "select user_id, spentity_id, ip_address, api_version, resource_url, consumer_key, log_timestamp from api_call_log where spentity_id = ?", new String[] { serviceProvider }, new RowMapper<ApiCallLog>() { @Override/*from ww w .j ava 2 s . c o m*/ public ApiCallLog mapRow(ResultSet rs, int rowNum) throws SQLException { ApiCallLog log = new ApiCallLog(); log.setApiVersion(rs.getString("api_version")); log.setConsumerKey(rs.getString("consumer_key")); log.setIpAddress(rs.getString("ip_address")); log.setResourceUrl(rs.getString("resource_url")); log.setSpEntityId(rs.getString("spentity_id")); log.setTimestamp(rs.getDate("log_timestamp")); log.setUserId(rs.getString("user_id")); return log; } }); }
From source file:com.leapfrog.academyspring.dao.impl.CourseDAOImpl.java
@Override public List<Course> getAll() { return jdbcTemplate.query(SQLConstants.COURSE_GETALL, new RowMapper<Course>() { @Override// w w w . ja va 2 s . c o m public Course mapRow(ResultSet rs, int i) throws SQLException { return mapData(rs); } }); }
From source file:com.sfs.whichdoctor.dao.WorkshopDAOImpl.java
/** * Used to get a Collection of WorkshopBeans for a specified GUID number. * * @param guid the guid//from w ww . j a v a 2 s .co m * @param fullResults the full results * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<WorkshopBean> load(final int guid, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Workshops for GUID: " + guid + " requested"); final String loadWorkshops = getSQL().getValue("workshop/load") + " WHERE workshop.Active = true AND workshop.ReferenceGUID = ?" + " ORDER BY workshop.Date"; Collection<WorkshopBean> workshops = new ArrayList<WorkshopBean>(); try { workshops = this.getJdbcTemplateReader().query(loadWorkshops, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadWorkshop(rs, true); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } return workshops; }
From source file:mylife.respository.userDAO.java
/** * * @return/*w ww. ja va 2 s . c o m*/ */ public List<user> getuserList() { return template.query("SELECT * FROM users", new RowMapper<user>() { public user mapRow(ResultSet rs, int row) throws SQLException { user u = new user(); u.setUsername(rs.getString("username")); u.setPassword(rs.getString(" Password")); u.setEnabled(rs.getBoolean("enabled")); return u; } }); }
From source file:repository.InteractionsDAO.java
public List<Interactions> getInteractionsList(int clientid) { return template.query("SELECT * FROM interactions WHERE clientid = " + clientid, new RowMapper<Interactions>() { @Override// w ww. j a v a 2 s . c om public Interactions mapRow(ResultSet rs, int row) throws SQLException { Interactions i = new Interactions(); i.setInteractionid(rs.getInt(1)); i.setClientid(rs.getInt(2)); i.setUsername(rs.getString(3)); // i.setFirstname(rs.getString("First Name")); // i.setLastname(rs.getString("Last Name")); i.setTypeofinteraction(rs.getString(4)); i.setInteractiontime(rs.getString(5)); return i; } }); }
From source file:ru.org.linux.spring.dao.MsgbaseDao.java
public MessageText getMessageText(int msgid) { return jdbcTemplate.queryForObject(QUERY_MESSAGE_TEXT, new RowMapper<MessageText>() { @Override//from ww w . j a v a 2 s . c om public MessageText mapRow(ResultSet resultSet, int i) throws SQLException { String text = resultSet.getString("message"); boolean lorcode = resultSet.getBoolean("bbcode"); return new MessageText(text, lorcode); } }, msgid); }
From source file:dao.CustomerDAO.java
public List getCircles(int userId) { String q = "SELECT CircleID\n" + " FROM circlemembership\n" + " WHERE UserID = " + userId; List ray = this.jdbcTemplate.queryForObject(q, new RowMapper<List>() { @Override/*from ww w. j a va2 s .com*/ public List mapRow(ResultSet rs, int rowNum) throws SQLException { List roy = new ArrayList(); roy.add(rs.getInt(1)); while (rs.next()) { roy.add(rs.getInt(1)); } return roy; } }); return ray; }
From source file:com.sfs.whichdoctor.dao.MemoDAOImpl.java
/** * Used to get a Collection of MemoBean details for a specified GUID number. * * @param guid the guid// www.j a v a 2 s .co m * @param fullResults the full results * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<MemoBean> load(final int guid, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Memos for GUID: " + guid + " requested"); final String loadMemo = getSQL().getValue("memo/load") + " WHERE memo.ReferenceGUID = ? AND memo.Active = true" + " ORDER BY memo.Priority ASC, guid.CreatedDate DESC"; Collection<MemoBean> memos = new ArrayList<MemoBean>(); try { memos = this.getJdbcTemplateReader().query(loadMemo, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadMemo(rs, fullResults); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.info("No results found for this search: " + ie.getMessage()); } return memos; }