com.springapp.mvc.mappers.ProductRowMapper.java Source code

Java tutorial

Introduction

Here is the source code for com.springapp.mvc.mappers.ProductRowMapper.java

Source

/*
 *
 *  *
 *  * Copyright (c) 2015 itembryo AG
 *  * All rights reserved.
 *  *
 *  * This software is the confidential and proprietary information of itembryo
 *  * ("Confidential Information"). You shall not disclose such Confidential
 *  * Information and shall use it only in accordance with the terms of the
 *  * license agreement you entered into with itembryo.
 *  *
 *  *
 *
 */

package com.springapp.mvc.mappers;

import com.springapp.mvc.data.Product;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;

import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by abhayphougat on 29/03/15.
 */
@Resource
public class ProductRowMapper implements RowMapper<Product> {
    @Override
    public Product mapRow(ResultSet resultSet, int i) throws SQLException {

        Product product = new Product();
        product.setCode(resultSet.getInt("code"));
        product.setDesc(resultSet.getString("description"));
        product.setName(resultSet.getString("name"));
        return product;
    }
}