List of usage examples for org.springframework.jdbc.core RowMapper RowMapper
RowMapper
From source file:bd.gov.forms.dao.FormDaoImpl.java
public Form getFormWithFields(String formId) { Form form = getForm(formId);/*from w w w . j a v a2s .co m*/ log.debug("formId: {}", form != null ? form.getId() : "form is null"); if (form != null) { List fields = jdbcTemplate.query("SELECT * FROM field WHERE form_id = ? order by field_order", new Object[] { form.getId() }, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Field fld = new Field(); fld.setId(rs.getInt("id")); fld.setFormId(rs.getInt("form_id")); fld.setFieldId(rs.getString("field_id")); fld.setType(rs.getString("type")); fld.setColName(rs.getString("col_name")); fld.setLabel(rs.getString("label")); fld.setHelpText(rs.getString("help_text")); fld.setOptions(rs.getString("options")); fld.setListDataId(rs.getInt("list_data_id")); fld.setDefaultValue(rs.getString("def_value")); fld.setFieldOrder(rs.getInt("field_order")); fld.setRequired(rs.getInt("required")); fld.setInputType(rs.getString("input_type")); return fld; } }); form.setFields(fields); } return form; }
From source file:com.sfs.whichdoctor.dao.SavedSearchDAOImpl.java
/** * Used to get a SearchBean for the specified SearchId number. * * @param searchId the search id/*w ww . ja v a2 s .c o m*/ * @return the search bean * @throws WhichDoctorDaoException the which doctor dao exception */ public final SearchBean loadId(final int searchId) throws WhichDoctorDaoException { dataLogger.info("Search Id: " + searchId + " requested"); SearchBean search = null; try { search = (SearchBean) this.getJdbcTemplateReader().queryForObject( this.getSQL().getValue("search/loadId"), new Object[] { searchId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadSearch(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return search; }
From source file:com.javacodegags.waterflooding.model.CriteriaImplemented.java
@Override public List<Integer> getCriteriaByFlooding(int id) { String sql = "select intermediatetoflooding.foreign_to_criteria" + " from intermediatetoflooding" + " where intermediatetoflooding.foreign_to_flooding=" + id + ";"; return jdbcTemplate.query(sql, new RowMapper<Integer>() { @Override/*from w w w . j a va 2 s. com*/ public Integer mapRow(ResultSet resultSet, int i) throws SQLException { return new Integer(resultSet.getInt("foreign_to_criteria")); } }); }
From source file:com.sfs.whichdoctor.dao.IsbEntityDAOImpl.java
/** * Loads an entity bean for an identified target/identifier combination. * * @param target the target/*from www. j a v a 2 s . co m*/ * @param identifier the identifier * * @return the isb entity bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final IsbEntityBean load(final String target, final String identifier) throws WhichDoctorDaoException { if (target == null) { throw new NullPointerException("The supplied target cannot be null"); } if (identifier == null) { throw new NullPointerException("The supplied identifier cannot be null"); } dataLogger.info("ISB entities for target: " + target + " requested"); IsbEntityBean entity = null; try { entity = (IsbEntityBean) this.getJdbcTemplateReader().queryForObject( this.getSQL().getValue("isbentity/loadTargetIdentifier"), new Object[] { target, identifier, true }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadIsbEntity(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return entity; }
From source file:ru.org.linux.user.UserDao.java
/** * // www . j a v a 2 s .co m * @param user * @return ? */ public UserInfo getUserInfoClass(User user) { return jdbcTemplate.queryForObject(queryUserInfoClass, new RowMapper<UserInfo>() { @Override public UserInfo mapRow(ResultSet resultSet, int i) throws SQLException { return new UserInfo(resultSet); } }, user.getId()); }
From source file:net.algem.security.UserDaoImpl.java
@Override public User findById(int id) { String query = "SELECT l.idper,l.login,l.profil,p.nom,p.prenom FROM " + TABLE + " l INNER JOIN " + PersonIO.TABLE + " p ON (l.idper = p.id) " + "WHERE l.idper = ? AND (p.ptype = " + Person.PERSON + " OR p.ptype = " + Person.ROOM + ")"; return jdbcTemplate.queryForObject(query, new RowMapper<User>() { @Override//from w ww. java 2 s. c o m public User mapRow(ResultSet rs, int rowNum) throws SQLException { return getFromRS(rs); } }, id); }
From source file:com.sfs.whichdoctor.dao.GroupDAOImpl.java
/** * Load a GroupBean for the specified GUID and provided load details. * * @param guid the guid/*from w w w. ja v a2 s . co m*/ * @param loadDetails the load details * * @return the group bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final GroupBean loadGUID(final int guid, final BuilderBean loadDetails) throws WhichDoctorDaoException { GroupBean group = null; final String loadSQL = getSQL().getValue("group/load") + " AND groups.Active = true AND groups.GUID = ?" + " GROUP BY groups.GroupId"; try { group = (GroupBean) this.getJdbcTemplateReader().queryForObject(loadSQL, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadGroup(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for the search: " + ie.getMessage()); } return group; }
From source file:om.edu.squ.squportal.portlet.dps.registration.postpone.db.PostponeDBImpl.java
/** * /*from www . ja va2 s . c om*/ * method name : getPostponesForStudents * @param studentNo * @param locale * @return * PostponeDBImpl * return type : List<PostponeDTO> * * purpose : List of postponed studies requested by a particular student * * Date : Aug 10, 2017 9:40:55 AM */ public List<PostponeDTO> getPostponesForStudents(String studentNo, Locale locale) { String SQL_POSTPONE_SELECT_RECORDS_BY_STUDENT = queryPostpone .getProperty(Constants.CONST_SQL_POSTPONE_SELECT_RECORDS_BY_STUDENT); RowMapper<PostponeDTO> rowMapper = new RowMapper<PostponeDTO>() { @Override public PostponeDTO mapRow(ResultSet rs, int rowNum) throws SQLException { PostponeDTO dto = new PostponeDTO(); Advisor advisor = new Advisor(); Supervisor supervisor = new Supervisor(); CollegeDean collegeDean = new CollegeDean(); DpsDean dpsDean = new DpsDean(); dto.setActivityDate(rs.getString(Constants.COST_COL_DPS_CREATE_DATE)); dto.setToCcYearCode(rs.getString(Constants.COST_COL_DPS_TO_COURSE_YEAR_CODE)); dto.setToSemCode(rs.getString(Constants.COST_COL_DPS_SEMESTER_CODE)); dto.setToSemName(rs.getString(Constants.COST_COL_DPS_SEMESTER_NAME)); if (null != rs.getString(Constants.CONST_COLMN_POSTPONE_OTHER_REASON)) { dto.setReasonDesc(rs.getString(Constants.CONST_COLMN_POSTPONE_OTHER_REASON)); } else { dto.setReasonDesc(rs.getString(Constants.CONST_COLMN_POSTPONE_REASON_NAME)); } dto.setCommentEng(rs.getString(Constants.CONST_COLMN_COMMENT)); if (rs.getString(Constants.CONST_COLMN_STUDENT_HAS_THESIS).equals(Constants.CONST_YES)) { supervisor.setApprovalcode(rs.getString(Constants.CONST_COLMN_APPROVAL_CODE_SUPERVISOR)); supervisor.setRoleStatus(rs.getString(Constants.CONST_COLMN_ROLE_SUPERVISOR_STATUS)); supervisor.setRoleStausIkon( RoleTagGlyphicon.showIkon(rs.getString(Constants.CONST_COLMN_ROLE_SUPERVISOR_STATUS))); advisor.setRoleStatus(Constants.CONST_NOT_USED); advisor.setRoleStausIkon(RoleTagGlyphicon.showIkon(Constants.CONST_NOT_USED)); } else { advisor.setApprovalcode(rs.getString(Constants.CONST_COLMN_APPROVAL_CODE_ADVISOR)); advisor.setRoleStatus(rs.getString(Constants.CONST_COLMN_ROLE_ADVISOR_STATUS)); advisor.setRoleStausIkon( RoleTagGlyphicon.showIkon(rs.getString(Constants.CONST_COLMN_ROLE_ADVISOR_STATUS))); supervisor.setRoleStatus(Constants.CONST_NOT_USED); supervisor.setRoleStausIkon(RoleTagGlyphicon.showIkon(Constants.CONST_NOT_USED)); } collegeDean.setApprovalcode(rs.getString(Constants.CONST_COLMN_APPROVAL_CODE_COLLEGE_DEAN)); collegeDean.setRoleStatus(rs.getString(Constants.CONST_COLMN_ROLE_COLLEGE_DEAN_STATUS)); collegeDean.setRoleStausIkon( RoleTagGlyphicon.showIkon(rs.getString(Constants.CONST_COLMN_ROLE_COLLEGE_DEAN_STATUS))); dpsDean.setApprovalcode(rs.getString(Constants.CONST_COLMN_APPROVAL_CODE_DPS_DEAN)); dpsDean.setRoleStatus(rs.getString(Constants.CONST_COLMN_ROLE_DPS_DEAN_STATUS)); dpsDean.setRoleStausIkon( RoleTagGlyphicon.showIkon(rs.getString(Constants.CONST_COLMN_ROLE_DPS_DEAN_STATUS))); dto.setAdvisor(advisor); dto.setSupervisor(supervisor); dto.setCollegeDean(collegeDean); dto.setDpsDean(dpsDean); dto.setStatusCode(rs.getString(Constants.CONST_COLMN_STATUS_CODE)); dto.setStatusCodeName(rs.getString(Constants.CONST_COLMN_STATUS_CODE_NAME)); if (rs.getString(Constants.CONST_COLMN_STATUS_CODE_NAME) .equals(Constants.CONST_SQL_STATUS_CODE_REJCT)) { dto.setStatusReject(true); } dto.setStatusDesc(rs.getString(Constants.CONST_COLMN_STATUS_DESC)); dto.setCommentEng(rs.getString(Constants.CONST_COLMN_COMMENT)); return dto; } }; Map<String, String> namedParameterMap = new HashMap<String, String>(); namedParameterMap.put("paramStdNo", studentNo); namedParameterMap.put("paramLocale", locale.getLanguage()); namedParameterMap.put("paramAdvisorRoleName", Constants.CONST_SQL_ROLE_NAME_ADVISOR); namedParameterMap.put("paramSupervisorRoleName", Constants.CONST_SQL_ROLE_NAME_SUPERVISOR); namedParameterMap.put("paramColDeanRoleName", Constants.CONST_SQL_ROLE_NAME_COL_DEAN); namedParameterMap.put("paramDpsDeanRoleName", Constants.CONST_SQL_ROLE_NAME_DPS_DEAN); namedParameterMap.put("paramFormName", Constants.CONST_FORM_NAME_DPS_POSTPONE_STUDY); return nPJdbcTemplDpsPostpone.query(SQL_POSTPONE_SELECT_RECORDS_BY_STUDENT, namedParameterMap, rowMapper); }
From source file:com.sfs.whichdoctor.dao.PaymentDAOImpl.java
/** * Used to get a PaymentBean for a specified GUID. * * @param guid the payment guid//w w w . j av a 2s .c o m * * @return the payment bean * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final PaymentBean loadGUID(final int guid) throws WhichDoctorDaoException { dataLogger.info("Payment GUID: " + guid + " requested"); final String loadPaymentGUID = getSQL().getValue("payment/load") + " WHERE payment.Active = true AND payment.GUID = ?"; PaymentBean payment = null; try { payment = (PaymentBean) this.getJdbcTemplateReader().queryForObject(loadPaymentGUID, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadPayment(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search:" + ie.getMessage()); } return payment; }