package com.acbook.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.acbook.common.enums.ExpenseType;
import com.acbook.dao.ExpenseDao;
import com.acbook.model.Expense;

@Repository("ExpenseDaoH2")
public class ExpenseDaoH2 implements ExpenseDao {

    private JdbcTemplate template;

    @Autowired
    public void setDataSource(DataSource ds) {
        template = new JdbcTemplate(ds);
    }

    private static final String SELECT_ALL = "SELECT * FROM expense";

    @Override
    public List<Expense> find() {
        // return template.query(SELECT_ALL, new BeanPropertyRowMapper<Expense>(Expense.class));
        return template.query(SELECT_ALL, new RowMapper<Expense>() {
            @Override
            public Expense mapRow(ResultSet rs, int rowNum) throws SQLException {
                Expense expense = new Expense();
                expense.setExpenseId(rs.getInt("EXPENSE_ID"));
                expense.setExpenseType(ExpenseType.getExpenseType(rs.getInt("EXPENSE_TYPE")));
                expense.setExpenseName(rs.getString("EXPENSE_NAME"));
                expense.setPrice(rs.getInt("PRICE"));
                expense.setExpenseDate(rs.getDate("EXPENSE_DATE"));
                expense.setOrd(rs.getInt("ORD"));
                expense.setPrcDate(rs.getDate("PRC_DATE"));
                return expense;
            }
        });
    }

}

@@ -799,24 +799,105 @@
 e%3E find() %7B%0A
+        // Enum%E3%82%92%E3%81%86%E3%81%BE%E3%81%8F%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%81%8C%E3%82%8F%E3%81%8B%E3%82%89%E3%81%AA%E3%81%8B%E3%81%A3%E3%81%9F%E3%81%AE%E3%81%A7%E3%80%81%E3%81%B2%E3%81%A8%E3%81%BE%E3%81%9ABeanPropertyRowMapper%E3%81%AF%E4%BD%BF%E3%82%8F%E3%81%9A%E3%80%81%E3%83%99%E3%82%BF%E3%81%AB%E5%87%A6%E7%90%86%E3%82%92%E6%9B%B8%E3%81%8F%E3%81%93%E3%81%A8%E3%81%AB%E3%81%97%E3%81%9F%E3%80%82%0A
         // r

Add Comment.