Example usage for org.springframework.jdbc.core RowMapper RowMapper

List of usage examples for org.springframework.jdbc.core RowMapper RowMapper

Introduction

In this page you can find the example usage for org.springframework.jdbc.core RowMapper RowMapper.

Prototype

RowMapper

Source Link

Usage

From source file:nu.yona.server.batch.jobs.SendSystemMessageBatchJob.java

private RowMapper<UUID> singleUUIDColumnRowMapper() {
    return new RowMapper<UUID>() {

        @Override//from w  w w  .  java 2s . com
        public UUID mapRow(ResultSet rs, int rowNum) throws SQLException {
            return UUID.fromString(rs.getString(1));
        }

    };
}

From source file:om.edu.squ.squportal.portlet.dps.grade.incomplete.db.IncompleteGradeDBImpl.java

public YearSemester getCurrentYearSem() {
    String SQL_GRADE_SELECT_RULE_TEST_CURRENT_YEAR_SEM = queryIncompleteGrade
            .getProperty(Constants.CONST_SQL_INCOMPLETE_GRADE_SELECT_RULE_TEST_CURRENT_YEAR_SEM);
    RowMapper<YearSemester> rowMapper = new RowMapper<YearSemester>() {

        @Override//from www.  j a v a 2  s .c  o m
        public YearSemester mapRow(ResultSet rs, int rowNum) throws SQLException {
            YearSemester yearSemester = new YearSemester();
            yearSemester.setYear(rs.getInt(Constants.COST_COL_DPS_COURSE_YEAR));
            yearSemester.setSemester(rs.getInt(Constants.COST_COL_DPS_SEMESTER_CODE));
            return yearSemester;
        }
    };

    Map<String, String> namedParameterMap = new HashMap<String, String>();
    return nPJdbcTemplDpsIncompleteGrade.queryForObject(SQL_GRADE_SELECT_RULE_TEST_CURRENT_YEAR_SEM,
            namedParameterMap, rowMapper);
}

From source file:com.sfs.whichdoctor.dao.EmailDAOImpl.java

/**
 * Load the EmailBeans that have the supplied domain name.
 *
 * @param domainName the address domain name
 * @return the collection of EmailBeans//from w w w .j a v  a  2s .  c  om
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<EmailBean> loadDomain(final String domainName) throws WhichDoctorDaoException {
    final String loadDomain = getSQL().getValue("email/load") + " " + getSQL().getValue("email/whereDomain");

    String domainSearch = "";
    if (StringUtils.isNotBlank(domainName)) {
        domainSearch = "%@" + domainName;
    }

    Collection<EmailBean> emailAddresses = new ArrayList<EmailBean>();

    if (StringUtils.isNotBlank(domainSearch)) {
        try {
            emailAddresses = this.getJdbcTemplateReader().query(loadDomain, new Object[] { domainSearch, true },
                    new RowMapper() {
                        public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                            return loadEmail(rs);
                        }
                    });

        } catch (IncorrectResultSizeDataAccessException ie) {
            dataLogger.debug("No results found for search: " + ie.getMessage());
        }
    }
    return emailAddresses;
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a SupervisorBean for a related rotation or organisation based
 * on the supplied hierarchy, relationship class and division parameters.
 *
 * @param referenceGUID - the GUID of the rotation or organisation
 * @param hierarchy - the hierarchy value (must be greater than zero)
 * @param relationshipClass - the relationship class
 * @param division - the training division
 *
 * @return - The identified supervisor. A null object is returned if no
 * supervisor is found, or if the hierarchy = 0 and/or the division
 * is null/empty string./*from  w w  w  .j av  a2 s . c  om*/
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final SupervisorBean load(final int referenceGUID, final int hierarchy, final String relationshipClass,
        final String division) throws WhichDoctorDaoException {

    dataLogger.info("Supervisor for reference GUID: " + referenceGUID + ", hierarchy: " + hierarchy
            + ", relationship class: " + relationshipClass + ", division: " + division);

    SupervisorBean supervisor = null;

    if (referenceGUID > 0 && hierarchy > 0 && StringUtils.isNotBlank(relationshipClass)
            && StringUtils.isNotBlank(division)) {

        final String loadSupervisorId = getSQL().getValue("supervisor/load")
                + " WHERE supervisors.Active = true AND" + " supervisors.ReferenceGUID = ? AND"
                + " relationshiptype.Value <= ? AND" + " relationshiptype.Class = ? AND"
                + " relationshiptype.Security = ?" + " ORDER BY relationshiptype.Value LIMIT 1";

        final BuilderBean loadDetails = new BuilderBean();
        loadDetails.setParameter("SUPERVISOR_PERSONOBJ", true);

        try {
            supervisor = (SupervisorBean) this.getJdbcTemplateReader().queryForObject(loadSupervisorId,
                    new Object[] { referenceGUID, hierarchy, relationshipClass, division }, 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 supervisor;
}

From source file:dao.CircleDAO.java

public int getPageId(int circleId) {
    String query = "SELECT PageId FROM hasa" + "\nWHERE CircleId = " + circleId;
    int pageid = this.jdbcTemplate.queryForObject(query, new RowMapper<Integer>() {
        @Override//from  w ww  . j  ava  2 s.  co  m
        public Integer mapRow(ResultSet rs, int rowNum) throws SQLException {
            return rs.getInt("PageId");
        }
    });
    return pageid;

}

From source file:com.arcane.dao.Impl.PatternDaoImpl.java

@Override
public TrippleBottom getTrippleBottom(String id) {
    //return requested triple bottom pattern
    LOG.info("Selecting requested pattern ", id);
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "SELECT * from tripplebottom where id=" + id;
    List<TrippleBottom> trippleBottom = jdbcTemplate.query(sql, new RowMapper<TrippleBottom>() {

        @Override//from w  w w .ja  va 2  s .  co  m
        public TrippleBottom mapRow(ResultSet rs, int rowNumber) throws SQLException {
            TrippleBottom trippleBottom1 = new TrippleBottom();
            trippleBottom1.setFirstMinPrice(rs.getDouble("firstMinPrice"));
            trippleBottom1.setSecondMinPrice(rs.getDouble("secondMinPrice"));
            trippleBottom1.setThirdMinPrice(rs.getDouble("thirdMinPrice"));
            trippleBottom1.setBreakPointPrice(rs.getDouble("breakPointPrice"));
            trippleBottom1.setFirstMaxPrice(rs.getDouble("firstMaxPrice"));
            trippleBottom1.setSecondMaxPrice(rs.getDouble("secondMaxPrice"));
            trippleBottom1.setFirstMin(rs.getString("firstMin"));
            trippleBottom1.setSecondMin(rs.getString("secondMin"));
            trippleBottom1.setThirdMin(rs.getString("thirdMin"));
            trippleBottom1.setBreakPoint(rs.getString("breakPoint"));
            trippleBottom1.setFirstMax(rs.getString("firstMax"));
            trippleBottom1.setSecondMax(rs.getString("secondMax"));
            return trippleBottom1;
        }

    });

    return trippleBottom.get(0);
}

From source file:om.edu.squ.squportal.portlet.dps.registration.dropw.db.DropWDBImpl.java

/**
 * /*  w  w  w . java2  s  .  c om*/
 * method name  : getCourseList
 * @param studentNo
 * @param studentStatCode
 * @param locale
 * @return
 * DropWDBImpl
 * return type  : List<DropWDTO>
 * 
 * purpose      : Get list of courses relates with drop with w from temp/helper table
 *
 * Date          :   Apr 11, 2017 5:33:34 PM
 */
public List<DropWDTO> getCourseList(String studentNo, String studentStatCode, Locale locale) {
    String SQL_DROPW_SELECT_COURSE_TEMP = queryDropWProps
            .getProperty(Constants.CONST_SQL_DROPW_SELECT_COURSE_TEMP);
    RowMapper<DropWDTO> rowMapper = new RowMapper<DropWDTO>() {

        @Override
        public DropWDTO mapRow(ResultSet rs, int rowNum) throws SQLException {
            DropWDTO dropWDTO = new DropWDTO();
            dropWDTO.setlAbrCourseNo(rs.getString(Constants.CONST_COLMN_L_ABR_CRSNO));
            dropWDTO.setCourseNo(rs.getString(Constants.CONST_COLMN_COURSE_NO));
            dropWDTO.setCourseName(rs.getString(Constants.CONST_COLMN_COURSE_NAME));
            dropWDTO.setSectionNo(rs.getString(Constants.CONST_COLMN_SECTION_NO));
            dropWDTO.setSectCode(rs.getString(Constants.CONST_COLMN_SECT_CODE));
            dropWDTO.setCredits(rs.getInt(Constants.CONST_COLMN_CREDITS));
            dropWDTO.setStatusDesc(rs.getString(Constants.CONST_COLMN_STATUS_DESC));
            if (rs.getString(Constants.CONST_COLMN_STATUS_CODE_NAME)
                    .equals(Constants.CONST_SQL_STATUS_CODE_NAME_PENDING)) {
                dropWDTO.setStatusPending(true);
            } else {
                dropWDTO.setStatusPending(false);
            }
            if (rs.getString(Constants.CONST_COLMN_STATUS_CODE_NAME)
                    .equals(Constants.CONST_SQL_STATUS_CODE_REJCT)) {
                dropWDTO.setStatusReject(true);
            } else {
                dropWDTO.setStatusReject(false);
            }

            dropWDTO.setRemarks(rs.getString(Constants.CONST_COLMN_COMMENT));
            return dropWDTO;
        }
    };

    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("paramStdNo", studentNo);
    paramMap.put("paramStdStatCode", studentStatCode);
    paramMap.put("paramLocale", locale.getLanguage());
    return nPJdbcTemplDpsDropW.query(SQL_DROPW_SELECT_COURSE_TEMP, paramMap, rowMapper);
}

From source file:com.havoc.hotel.admin.dao.impl.BookingDAOImpl.java

@Override
public List<Booking> getLast() throws SQLException {
    return jdbcTemplate.query(SQLConstant.BOOKING_GETLAST, new RowMapper<Booking>() {

        @Override/* ww w .  j  a v a  2 s.c om*/
        public Booking mapRow(ResultSet rs, int i) throws SQLException {
            return mapData(rs);
        }
    });
}

From source file:com.sfs.whichdoctor.dao.EmailRecipientDAOImpl.java

/**
 * Load a collection of EmailRecipientBeans for a specified referenceGUID.
 *
 * @param referenceGUID the reference guid
 * @return the collection/*w  w  w . j a  v  a  2s  . co m*/
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<EmailRecipientBean> load(final int referenceGUID) throws WhichDoctorDaoException {

    dataLogger.info("Requested EmailRecipients for ReferenceGUID: " + referenceGUID);

    final String loadRecipients = getSQL().getValue("emailRecipient/load");

    Collection<EmailRecipientBean> emailRecipients = new ArrayList<EmailRecipientBean>();

    try {
        emailRecipients = this.getJdbcTemplateReader().query(loadRecipients, new Object[] { referenceGUID },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadEmailRecipient(rs);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        // No results found for this search
        dataLogger.info("No results found for this EmailRecipient search");
    }
    return emailRecipients;
}