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.ewcms.component.hot.dao.HotDAO.java

public List<Hot> findHot() {
    String sql = "Select t3.title,t3.url From component_counter t1,content_article_main t2,content_article t3 "
            + "Where t1.article_id = t2.article_id And t2.article_id = t3.id "
            + "And t2.reference=false And t3.status='RELEASE' And t3.url is not null "
            //+"And t3.published > (CURRENT_DATE - 30)"
            + "Order by t1.counter Desc Limit 3";

    return jdbcTemplate.query(sql, new RowMapper<Hot>() {
        @Override//from  w w  w .  j  a va2s  . c  o  m
        public Hot mapRow(ResultSet rs, int rowNum) throws SQLException {
            Hot hot = new Hot();

            hot.setTitle(rs.getString("title"));
            hot.setUrl(rs.getString("url"));
            return hot;
        }

    });
}

From source file:com.leapfrog.sms.dao.impl.CourseDAOImpl.java

@Override
public Course getById(int id) {
    return jdbcTemplate.queryForObject(SqlConstant.COURSE_GETBYID, new Object[] { id },
            new RowMapper<Course>() {

                @Override/*from w ww  .  j  ava  2  s  .  co  m*/
                public @ResponseBody Course mapRow(ResultSet rs, int i) throws SQLException {
                    return mapData(rs);
                }
            });
}

From source file:com.mesut.daopattern.OffersDAO.java

/**
 * Gets List of offers with jdbc template<br/>
 * <strong>sql query:</strong> <code>select * from offers</code>
 * @return List<Offer> //from   www .j a v  a 2  s. c  o  m
 * @see List
 * @see Offer
 */
public List<Offer> findOffers() {
    return jdbc.query("select * from offers", new RowMapper<Offer>() {

        public Offer mapRow(ResultSet rs, int i) throws SQLException {
            Offer offer = new Offer();
            offer.setId(rs.getInt("id"));
            offer.setName(rs.getString("name"));
            offer.setEmail(rs.getString("email"));
            offer.setText(rs.getString("text"));
            return offer;
        }
    });
}

From source file:com.ewcms.component.online.dao.CitizenDAO.java

public List<Citizen> getAll() {
    String sql = "Select * From content_citizen Order By id Asc";

    return jdbcTemplate.query(sql, new RowMapper<Citizen>() {

        @Override/*  w  w  w  . j  a  v  a 2 s.co m*/
        public Citizen mapRow(ResultSet rs, int rowNum) throws SQLException {
            return citizenMapRow(rs);
        }
    });
}

From source file:com.mohit.program.DAO.impl.ProductDAOImpl.java

@Override
public List<Product> getAll(boolean availability) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_product WHERE 1=1 ";

    if (availability) {
        sql += " AND status=1 ";
    }/*from   w  w  w.j  a v  a2 s  .  c o  m*/

    return jdbcTemplate.query(sql, new RowMapper<Product>() {

        @Override
        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.imps.struts2base.dao.UsuarioDAOImpl.java

@Override
public List<Usuario> buscarUsuarioPorCodigo(String codigo) {
    return this.jdbcTemplate.query("SELECT * FROM usuario WHERE cod_usuario= ?", new RowMapper() {

        @Override/*from  w w  w.j a va 2  s.c o m*/
        public Object mapRow(ResultSet rs, int i) throws SQLException {
            Usuario unUsuario = new Usuario();
            unUsuario.setUsername(rs.getString("cod_usuario"));
            unUsuario.setPassword(rs.getString("des_password"));
            unUsuario.setAccountNonExpired(rs.getString("in_cuenta_expirada").equals("N") ? true : false);
            unUsuario.setAccountNonLocked(rs.getString("in_cuenta_bloqueada").equals("N") ? true : false);
            unUsuario.setCredentialsNonExpired(
                    rs.getString("in_credencial_expirada").equals("N") ? true : false);
            unUsuario.setEnabled(rs.getString("in_habilitado").equals("S") ? true : false);
            return unUsuario;

        }

    }, codigo);
}

From source file:com.leapfrog.SpringMaven.DAOImpl.UserDAOImpl.java

@Override
public List<User> getAll() throws SQLException, ClassNotFoundException {
    String query = "SELECT * from tbl_user";
    return jdbcTemplate.query(query, new RowMapper<User>() {

        @Override//w w  w .  ja  va 2 s.  c o  m
        public User mapRow(ResultSet rs, int i) throws SQLException {
            User user = new User();

            user.setId(rs.getInt("user_id"));
            user.setUserName(rs.getString("user_name"));
            user.setPassword(rs.getString("password"));
            user.setEmail(rs.getString("email"));
            user.setStatus(rs.getBoolean("status"));

            return user;

        }
    });

}

From source file:org.smigo.species.JdbcFamilyDao.java

@Override
public List<Family> getFamilies() {
    final String sql = String.format(SELECT);
    return jdbcTemplate.query(sql, new RowMapper<Family>() {
        @Override/*from  w w  w .  ja v a 2 s  . com*/
        public Family mapRow(ResultSet rs, int rowNum) throws SQLException {
            return new Family(rs.getInt("id"), rs.getString("name"));
        }
    });
}

From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SalesDAOImpl.java

@Override
public List<Sales> getALL(boolean status) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_sales WHERE 1=1";

    if (status) {
        sql += " AND status=1 ";
    }/*from  w w  w.  jav  a 2 s.  co  m*/
    return jdbcTemplate.query(sql, new RowMapper<Sales>() {

        @Override
        public Sales mapRow(ResultSet rs, int i) throws SQLException {
            Sales s = new Sales();
            s.setId(rs.getInt("sales_id"));
            s.setProductId(rs.getInt("product_id"));
            s.setSellingPrice(rs.getInt("selling_price"));
            s.setQuantity(rs.getInt("quantity"));
            s.setDiscount(rs.getBigDecimal("discount"));
            s.setTotalCost(rs.getInt("total_cost"));
            s.setSalesDate(rs.getDate("sales_date"));
            s.setPaymentMethod(rs.getString("payment_method"));
            s.setStatus(rs.getBoolean("status"));

            return s;
        }
    });
}

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

@Override
public List<Room> getALL() throws SQLException {
    return jdbcTemplate.query(SQLConstant.ROOM_GETALL, new RowMapper<Room>() {
        @Override/*  ww  w  .ja v a  2 s.c  o  m*/
        public Room mapRow(ResultSet rs, int i) throws SQLException {
            return mapData(rs);
        }
    });
}