List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:com.springsource.greenhouse.members.JdbcProfileRepository.java
public List<ConnectedProfile> findConnectedProfiles(Long accountId) { return jdbcTemplate.query(SELECT_CONNECTED_PROFILES, new RowMapper<ConnectedProfile>() { public ConnectedProfile mapRow(ResultSet rs, int row) throws SQLException { String displayName = displayNameFor(rs.getString("providerId")); return new ConnectedProfile(displayName, rs.getString("profileUrl")); }//w w w . ja v a 2 s . c om }, accountId.toString()); }
From source file:com.sfs.dao.GadgetDAOImpl.java
/** * Load a GadgetBean based on its url./*from w ww . j av a2 s . c o m*/ * * @param url the url * * @return the gadget bean * * @throws SFSDaoException the SFS dao exception */ public final GadgetBean load(final String url) throws SFSDaoException { GadgetBean gadgetBean = null; if (url == null) { throw new SFSDaoException("Error: URL cannot be null"); } if (url.compareTo("") == 0) { throw new SFSDaoException("Error: URL cannot be an empty string"); } dataLogger.debug("Load gadget for: " + url); try { gadgetBean = (GadgetBean) this.getJdbcTemplateReader() .queryForObject(this.getSQL().getValue("gadget/load"), new Object[] { url }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadGadget(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return gadgetBean; }
From source file:mylife.respository.interactionsDAO.java
/** * * @return/* w ww .j a v a2s . c om*/ */ public List<interactions> getinteractionsList() { return template.query("SELECT * FROM interactions", new RowMapper<interactions>() { public interactions mapRow(ResultSet rs, int row) throws SQLException { interactions i = new interactions(); i.setInteraction_Id(rs.getInt("interactionid")); i.setClients_id(rs.getInt(" Clients_id")); i.setDate_of_contact(rs.getString("Date_of_contact")); i.setContact_name(rs.getString("First_name")); i.setContact_type(rs.getString("Contact_type")); i.setConversation(rs.getString("Conversation")); return i; } }); }
From source file:com.sfs.whichdoctor.dao.IsbMessageDAOImpl.java
/** * Used to get a IsbMessageBean for the the specified ISB Message Id. * Returns null if no isb message found//from w w w . ja v a 2 s. co m * * @param isbMessageId the isb message id * * @return the isb message bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final IsbMessageBean load(final int isbMessageId) throws WhichDoctorDaoException { dataLogger.info("ISB message id: " + isbMessageId + " requested"); IsbMessageBean isbMessage = null; try { isbMessage = (IsbMessageBean) this.getIsbJdbcTemplate().queryForObject( this.getSQL().getValue("isbmessage/loadId"), new Object[] { isbMessageId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadIsbMessageBean(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return isbMessage; }
From source file:com.sfs.dao.FieldMapDAOImpl.java
/** * Load a map of FieldMapBeans based on the supplied map class and type * variables.// w ww . j ava 2s .co m * * @param mapClass the map class * @param mapType the map type * * @return the map< string, field map bean> * * @throws SFSDaoException the SFS dao exception */ @SuppressWarnings("unchecked") public final Map<String, FieldMapBean> load(final String mapClass, final String mapType) throws SFSDaoException { if (mapClass == null) { throw new SFSDaoException("Error: field map class cannot be null"); } if (mapClass.compareTo("") == 0) { throw new SFSDaoException("Error: field map class cannot be an " + "empty string"); } if (mapType == null) { throw new NullPointerException("Error: field map type cannot " + "be null"); } dataLogger.info("Field maps for: " + mapClass + " - " + mapType + " requested"); Map<String, FieldMapBean> fieldHash = new HashMap<String, FieldMapBean>(); Collection<FieldMapBean> fieldMaps = new ArrayList<FieldMapBean>(); try { fieldMaps = this.getJdbcTemplateReader().query(this.getSQL().getValue("fieldMap/loadName"), new Object[] { mapClass, mapType }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadFieldMap(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } for (FieldMapBean fieldMap : fieldMaps) { fieldHash.put(fieldMap.getName(), fieldMap); } return fieldHash; }
From source file:com.imps.struts2base.dao.UsuarioDAOImpl.java
@Override public List<? extends GrantedAuthority> buscarSectoresDeUsuariosPorCodigo(String codigo) { return this.jdbcTemplate.query( "select sector_perfil from sectores s, usuario u where u.usuario_sector=s.sector_id and cod_usuario = ?", new RowMapper() { @Override/*from w w w . j av a 2 s . com*/ public Object mapRow(ResultSet rs, int i) throws SQLException { Sectores sectores = new Sectores(); sectores.setNombrePerfil(rs.getString("sector_perfil")); return sectores; } }, codigo); }
From source file:com.abcd.employeemaven.dao.impl.DepartmentDaoImpl.java
@Override public Department getById(int id) { return jdbcTemplate.queryForObject(DepartmentSQL.GETBYID, new Object[] { id }, new RowMapper<Department>() { @Override/*w w w . j a v a2 s . co m*/ public Department mapRow(ResultSet rs, int i) throws SQLException { return mapData(rs); } }); }
From source file:shell.framework.cache.SystemCacheInitializer.java
/** * ?userCache?//from ww w.j a v a2 s . c om * <id,> => <usercode,user> */ @SuppressWarnings("all") public void userInitial() { String sql = "select * from TBL_SYS_USER where IS_VALID='" + SystemParam.IS_VALID + "'"; List<?> userList = jdbcBaseDao.query(sql, new RowMapper<Object>() { /* (non-Javadoc) * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int) */ public Object mapRow(ResultSet rs, int rowNum) throws SQLException { TblSysUser user = new TblSysUser(); Map<String, String> propertyMap = new HashMap<String, String>(); propertyMap.put("createdTime", "CREATE_TIME"); propertyMap.put("updatedTime", "UPDATE_TIME"); PopulateUtil.populate(user, rs, propertyMap); CacheUtil.putValue("userCache", user.getUserCode(), user); return user; } }); }
From source file:com.seajas.search.utilities.spring.security.dao.UserDAO.java
/** * Find a given user by username./* w w w . j a v a2 s. co m*/ * * @param username * @return User */ public User findUserByUsername(final String username) { String sql = "SELECT id, username, password, fullname, is_enabled FROM user WHERE username = ?"; RowMapper<User> mapper = new RowMapper<User>() { @Override public User mapRow(final ResultSet resultSet, final int rowNum) throws SQLException { Integer id = resultSet.getInt("id"); String username = resultSet.getString("username"); String password = resultSet.getString("password"); String fullname = resultSet.getString("fullname"); Boolean isEnabled = resultSet.getInt("is_enabled") == 1 ? true : false; return new User(id, username, password, fullname, isEnabled); } }; try { return jdbc.queryForObject(sql, mapper, username); } catch (DataAccessException e) { return null; } }