List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:bd.gov.forms.dao.UserDaoImpl.java
public User getUser(String userName, String password) { try {/*from ww w. j a v a2s . c o m*/ return (User) jdbcTemplate.queryForObject("SELECT * FROM user WHERE user = ? and password=?", new Object[] { userName, password }, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setSysId(rs.getString("sys_id")); user.setName(rs.getString("name")); user.setTitle(rs.getString("title")); user.setUserName(rs.getString("user")); user.setMobile(rs.getString("mobile")); user.setEmail(rs.getString("email")); user.setAdmin(rs.getInt("admin")); user.setActive(rs.getInt("active")); return user; } }); } catch (Exception ex) { log.debug("Exception in getUser().", ex); return null; } }
From source file:com.javacodegags.waterflooding.model.CriteriaImplemented.java
@Override public List<Criteria> getListById(int id) { String sql = "SELECT criteria.id, criteria_value, formula " + "FROM intermediate " + "INNER JOIN caption " + "ON intermediate.foreign_to_caption=caption.Id " + "INNER JOIN criteria " + "ON intermediate.foreign_to_criteria=criteria.Id " + "Where intermediate.foreign_to_caption=" + id + ";"; List<Criteria> listCriteria = jdbcTemplate.query(sql, new RowMapper<Criteria>() { @Override//from w w w. j a v a 2 s. c om public Criteria mapRow(ResultSet rs, int rowNum) throws SQLException { Criteria criteria = new Criteria(); criteria.setId(rs.getInt("id")); criteria.setValue(rs.getDouble("criteria_value")); criteria.setFormula(rs.getString("formula")); return criteria; } }); return listCriteria; }
From source file:com.krawler.spring.calendar.calendarmodule.JdbcCalendarUserDao.java
@Override public List<DeskeraCalendar> getSelectedCalendars(String referenceId) { String query = "select distinct m.cid from calendarusermap m where m.userid=?"; List<String> list = queryJDBC(query, new Object[] { referenceId }, new RowMapper<String>() { @Override/* w w w. ja v a 2 s . c o m*/ public String mapRow(ResultSet rs, int rowNum) throws SQLException { // TODO Auto-generated method stub return rs.getString("cid"); } }); return super.getCalendars(list.toArray(new String[] {})); }
From source file:com.mohit.program.DAO.impl.ProductDAOImpl.java
@Override public Product getById(int id) throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_product WHERE product_id=?"; return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Product>() { @Override//from w w w . ja v a2 s . c o m public Product mapRow(ResultSet rs, int i) throws SQLException { Product p = new Product(); p.setId(rs.getInt("product_id")); p.setProductName(rs.getString("product_name")); p.setCostPrice(rs.getString("cost_price")); p.setSellingPrice(rs.getString("selling_price")); p.setQuantityAvailable(rs.getInt("quantity_available")); p.setAddedDate(rs.getDate("added_date")); p.setModifiedDate(rs.getDate("modified_date")); p.setStatus(rs.getBoolean("status")); return p; } }); }
From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java
/** * Used to get a Collection of SupervisorBeans for a specified GUID. * * @param guid the guid/*from w w w . j a v a2 s . co m*/ * @param loadDetails the load details * * @return the collection< supervisor bean> * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<SupervisorBean> load(final int guid, final BuilderBean loadDetails) throws WhichDoctorDaoException { dataLogger.info("Supervisors for GUID: " + guid + " requested"); final String loadSupervisors = getSQL().getValue("supervisor/load") + " WHERE supervisors.Active = true AND supervisors.ReferenceGUID = ?" + " ORDER BY supervisors.OrderId ASC, relationshiptype.Class ASC," + " relationshiptype.Name ASC, people.LastName ASC"; Collection<SupervisorBean> supervisors = new ArrayList<SupervisorBean>(); try { supervisors = this.getJdbcTemplateReader().query(loadSupervisors, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadSupervisor(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return supervisors; }
From source file:com.ewcms.content.particular.dao.FrontEmployeArticleDAO.java
public List<EmployeArticle> findEmployeArticleByPage(int page, int row) { String sql = "Select * " + "From particular_employe_article where release=true " + "Order By published desc Limit ? OffSet ?"; int offset = page * row; Object[] params = new Object[] { row, offset }; List<EmployeArticle> list = jdbcTemplate.query(sql, params, new RowMapper<EmployeArticle>() { @Override//from w w w . j a v a2 s .c o m public EmployeArticle mapRow(ResultSet rs, int rowNum) throws SQLException { return interactionRowMapper(rs); } }); return list; }
From source file:dao.CircleDAO.java
public Posts setPostData(Posts post) { String query =/*from w ww . j a v a 2s.c om*/ "SELECT a.UserId, b.* " + "\nFROM writes a, post b " + "\nWHERE a.PostId = " + post.getPostID() + " AND b.PostId = " + post.getPostID(); Posts post2 = this.jdbcTemplate.queryForObject(query, new RowMapper<Posts>() { @Override public Posts mapRow(ResultSet rs, int rowNum) throws SQLException { Posts posts = new Posts(); posts.setAuthor(rs.getInt("UserId")); posts.setDate(rs.getDate("Date").toString()); posts.setContent(rs.getString("Content")); return posts; } }); post.setPosterName(getName(post2.getAuthor())); post.setAuthor(post2.getAuthor()); post.setDate(post2.getDate()); post.setContent(post2.getContent()); return post; }
From source file:shell.framework.organization.user.service.impl.TblSysUserService4JdbcImpl.java
public VOResult findByPagination(int currentPage, int pageSize, TblSysUserVO userVO) { StringBuffer sql = new StringBuffer("select * from TBL_SYS_USER user"); if (userVO != null) { sql.append(" where 1=1"); ///* w ww . j a va2 s .c o m*/ if (userVO.getFullName() != null && !"".equals(userVO.getFullName())) { sql.append(" and user.FULLNAME like '%" + userVO.getFullName().trim() + "%'"); } //ID if (userVO.getUserCode() != null && !"".equals(userVO.getUserCode())) { sql.append(" and user.USERCODE='" + userVO.getUserCode().trim() + "'"); } //? if (userVO.getTelephone() != null && !"".equals(userVO.getTelephone())) { sql.append(" and user.TELEPHONE='" + userVO.getTelephone().trim() + "'"); } } VOResult voResult = jdbcBaseDao.query(sql.toString(), 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); return user; } }, currentPage, pageSize); return voResult; }
From source file:eionet.meta.dao.mysql.VocabularyConceptDAOImpl.java
/** * {@inheritDoc}//from ww w . jav a 2 s .c o m */ @Override public List<VocabularyConcept> getVocabularyConcepts(int vocabularyFolderId) { Map<String, Object> params = new HashMap<String, Object>(); params.put("vocabularyFolderId", vocabularyFolderId); StringBuilder sql = new StringBuilder(); sql.append( "select VOCABULARY_CONCEPT_ID, IDENTIFIER, LABEL, DEFINITION, NOTATION, STATUS, ACCEPTED_DATE, "); sql.append("NOT_ACCEPTED_DATE, STATUS_MODIFIED "); sql.append("from VOCABULARY_CONCEPT where VOCABULARY_ID=:vocabularyFolderId order by IDENTIFIER + 0"); List<VocabularyConcept> resultList = getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowMapper<VocabularyConcept>() { @Override public VocabularyConcept mapRow(ResultSet rs, int rowNum) throws SQLException { VocabularyConcept vc = new VocabularyConcept(); vc.setId(rs.getInt("VOCABULARY_CONCEPT_ID")); vc.setIdentifier(rs.getString("IDENTIFIER")); vc.setLabel(rs.getString("LABEL")); vc.setDefinition(rs.getString("DEFINITION")); vc.setNotation(rs.getString("NOTATION")); vc.setStatus(rs.getInt("STATUS")); vc.setAcceptedDate(rs.getDate("ACCEPTED_DATE")); vc.setNotAcceptedDate(rs.getDate("NOT_ACCEPTED_DATE")); vc.setStatusModified(rs.getDate("STATUS_MODIFIED")); return vc; } }); return resultList; }
From source file:org.zenoss.zep.dao.impl.IndexMetadataDaoImpl.java
@Override @TransactionalReadOnly//www .j av a 2 s .c o m public IndexMetadata findIndexMetadata(String indexName) throws ZepException { final String sql = "SELECT * FROM index_metadata WHERE zep_instance=:zep_instance AND index_name=:index_name"; Map<String, Object> fields = new HashMap<String, Object>(); fields.put(COLUMN_ZEP_INSTANCE, uuidConverter.toDatabaseType(zepInstanceId)); fields.put(COLUMN_INDEX_NAME, indexName); final List<IndexMetadata> l = this.template.query(sql, new RowMapper<IndexMetadata>() { @Override public IndexMetadata mapRow(ResultSet rs, int rowNum) throws SQLException { IndexMetadata md = new IndexMetadata(); md.setZepInstance(uuidConverter.fromDatabaseType(rs, COLUMN_ZEP_INSTANCE)); md.setIndexName(rs.getString(COLUMN_INDEX_NAME)); md.setIndexVersion(rs.getInt(COLUMN_INDEX_VERSION)); md.setIndexVersionHash(rs.getBytes(COLUMN_INDEX_VERSION_HASH)); return md; } }, fields); return (l.isEmpty()) ? null : l.get(0); }