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:com.arcane.dao.Impl.PatternDaoImpl.java

@Override
public List<TrippleBottom> getTrippleBottomList() {
    //return all triple bottom patterns
    LOG.info("Returning all triple bottom patterns");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "SELECT * from tripplebottom";
    List<TrippleBottom> listPattern = jdbcTemplate.query(sql, new RowMapper<TrippleBottom>() {

        @Override//from   ww  w  . j a v a 2 s  .  com
        public TrippleBottom mapRow(ResultSet rs, int rowNumber) throws SQLException {
            TrippleBottom pattern = new TrippleBottom();
            pattern.setId(rs.getInt("id"));
            pattern.setName(rs.getString("name"));
            pattern.setFirstMin(rs.getString("firstMin"));
            pattern.setSecondMin(rs.getString("secondMin"));
            pattern.setThirdMin(rs.getString("thirdMin"));
            pattern.setBreakPoint(rs.getString("breakPoint"));
            pattern.setFirstMinPrice(rs.getDouble("fistMinPrice"));
            pattern.setSecondMinPrice(rs.getDouble("secondMinPrice"));
            pattern.setThirdMinPrice(rs.getDouble("thirdMinPrice"));
            pattern.setBreakPointPrice(rs.getDouble("breakPointPrice"));
            pattern.setFirstMax(rs.getString("firstMax"));
            pattern.setFirstMaxPrice(rs.getDouble("firstMaxPrice"));
            pattern.setSecondMax(rs.getString("secondMax"));
            pattern.setSecondMaxPrice(rs.getDouble("secondMaxPrice"));
            return pattern;
        }

    });
    return listPattern;
}

From source file:shell.framework.organization.department.service.impl.TblSysDepartmentServiceI4JdbcImpl.java

public VOResult findByPagination(int currentPage, int pageSize, TblSysDepartmentVO departmentVO) {
    StringBuffer sql = new StringBuffer("select * from TBL_SYS_DEPARTMENT department");
    sql.append(" where department.IS_VALID = '" + SystemParam.IS_VALID + "'");
    //??/*from  www  .j a va2  s .co m*/
    if (departmentVO.getDepartmentName() != null && !"".equals(departmentVO.getDepartmentName())) {
        sql.append(" and department.DEPARTMENT_NAME like '%" + departmentVO.getDepartmentName().trim() + "%'");
    }
    //   
    if (departmentVO.getDepartmentType() != null && !"".equals(departmentVO.getDepartmentType())) {
        sql.append(" and department.DEPARTMENT_TYPE = '" + departmentVO.getDepartmentType().trim() + "'");
    }
    //?
    if (departmentVO.getIsVD() != null && !"".equals(departmentVO.getIsVD())) {
        sql.append(" and department.IS_VD = '" + departmentVO.getIsVD().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 {
            TblSysDepartment department = new TblSysDepartment();
            Map<String, String> propertyMap = new HashMap<String, String>();
            propertyMap.put("departmentName", "DEPARTMENT_NAME");
            propertyMap.put("departmentType", "DEPARTMENT_TYPE");
            propertyMap.put("organizationID", "ORGANIZATION_ID");
            propertyMap.put("parentID", "PARENT_ID");
            propertyMap.put("orderID", "ORDER_NO");
            propertyMap.put("isValid", "IS_VALID");
            propertyMap.put("isVD", "IS_VD");

            PopulateUtil.populate(department, rs, propertyMap);
            return department;
        }

    }, currentPage, pageSize);
    return voResult;
}

From source file:org.simbasecurity.core.task.VerifyAuditLogIntegrityTask.java

private RowMapper<VerifyAuditLogEvent> getRowMapper() {
    return new RowMapper<VerifyAuditLogEvent>() {
        @Override//from  w  ww  .  ja va 2 s  .c om
        public VerifyAuditLogEvent mapRow(ResultSet rs, int rowNum) throws SQLException {
            VerifyAuditLogEvent event = new VerifyAuditLogEvent();
            event.setTimestamp(rs.getLong(TIME_STAMP));
            event.setUserName(rs.getString(USERNAME));
            event.setSsoToken(rs.getString(SSOTOKEN));
            event.setRemoteIp(rs.getString(REMOTE_IP));
            event.setMessage(rs.getString(MESSAGE));
            event.setName(rs.getString(NAME));
            event.setFirstName(rs.getString(FIRSTNAME));
            event.setUserAgent(rs.getString(USERAGENT));
            event.setHost(rs.getString(HOSTSERVERNAME));
            event.setEventCategory(rs.getString(EVENTCATEGORY));
            event.setDigest(rs.getString(DIGEST));
            event.setRequestUrl(rs.getString(REQUESTURL));
            event.setChainId(rs.getString(CHAINID));
            return event;
        }
    };
}

From source file:org.ohmage.query.impl.CampaignDocumentQueries.java

@Override
public Document.Role getCampaignDocumentRole(String campaignId, String documentId) throws DataAccessException {
    try {/*from   w  w  w  .  ja  v a  2s .  c  o  m*/
        return getJdbcTemplate().queryForObject(SQL_GET_CAMPAIGN_DOCUMENT_ROLE,
                new Object[] { campaignId, documentId }, new RowMapper<Document.Role>() {
                    @Override
                    public Document.Role mapRow(ResultSet rs, int rowNum) throws SQLException {
                        return Document.Role.getValue(rs.getString("role"));
                    }
                });
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("A campaign has more than one role with a document.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException("Error executing SQL '" + SQL_GET_CAMPAIGN_DOCUMENT_ROLE
                + "' with parameters: " + campaignId + ", " + documentId, e);
    }
}

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

/**
 * Load the expense claim bean.//from   w ww. j a  v  a 2s.c o m
 *
 * @param expenseClaimId the expense claim id
 * @return the expense claim bean
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final ExpenseClaimBean load(final int expenseClaimId) throws WhichDoctorDaoException {

    dataLogger.info("Getting expenseClaimId:" + expenseClaimId);

    final String loadId = getSQL().getValue("expenseclaim/load") + " WHERE expenseclaim.ExpenseClaimId = ?";

    ExpenseClaimBean expenseClaim = null;
    try {
        expenseClaim = (ExpenseClaimBean) this.getJdbcTemplateReader().queryForObject(loadId,
                new Object[] { expenseClaimId }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadExpenseClaim(rs);
                    }
                });

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

From source file:org.onesun.atomator.test.dao.AbderaEntryDAOImpl.java

@SuppressWarnings("unchecked")
@Override/*from  w ww  .  ja v  a2  s  .c  o  m*/
public List<Entry> get(String query, Object[] object) {
    /**
     * Implement the RowMapper callback interface
     */
    try {
        return Configuration.getJdbcTemplate().query(query, object, new RowMapper() {
            public Object mapRow(ResultSet resultSet, int rowNum) throws SQLException {
                return newAbderaEntry(resultSet);
            }
        });
    } catch (EmptyResultDataAccessException e) {
        return null;
    }
}

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

/**
 * Used to ge an Collection of QualificationBean details for a specified GUID.
 *
 * @param guid the guid// www. java 2 s.c om
 * @param fullResults the full results
 * @return the collection
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<QualificationBean> load(final int guid, final boolean fullResults)
        throws WhichDoctorDaoException {

    dataLogger.info("Qualifications for GUID: " + guid + " requested");

    final String loadQualifications = getSQL().getValue("qualification/load")
            + " WHERE qualification.Active = true AND qualification.ReferenceGUID = ?"
            + " ORDER BY qualification.Year ASC";

    Collection<QualificationBean> qualifications = new ArrayList<QualificationBean>();

    try {
        qualifications = this.getJdbcTemplateReader().query(loadQualifications, new Object[] { guid },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadQualification(rs);
                    }
                });

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

From source file:com.sfs.dao.FinancialTypeDAOImpl.java

/**
 * Load a single FinancialTypeBean for the supplied id.
 *
 * @param financialTypeId the financial type id
 *
 * @return the financial type bean//ww w  . j ava 2  s  . com
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final FinancialTypeBean load(final int financialTypeId) throws SFSDaoException {
    if (financialTypeId == 0) {
        throw new SFSDaoException("FinancialTypeId value cannot be 0");
    }

    FinancialTypeBean financialTypeBean = null;

    try {
        financialTypeBean = (FinancialTypeBean) this.getJdbcTemplateReader().queryForObject(
                this.getSQL().getValue("financialType/loadId"), new Object[] { financialTypeId },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadDetails(rs);
                    }
                });

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

    return financialTypeBean;
}

From source file:com.ewcms.content.particular.dao.FrontProjectArticleDAO.java

public List<ProjectArticle> findProjectArticleByPage(int page, int row) {
    String sql = "Select * " + "From particular_project_article where release=true "
            + "Order By published desc Limit ? OffSet ?";
    int offset = page * row;
    Object[] params = new Object[] { row, offset };
    List<ProjectArticle> list = jdbcTemplate.query(sql, params, new RowMapper<ProjectArticle>() {

        @Override/*  ww w.  j av  a 2 s . com*/
        public ProjectArticle mapRow(ResultSet rs, int rowNum) throws SQLException {
            return interactionRowMapper(rs);
        }
    });

    return list;
}