<commit_before>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;
            }
        });
    }

}<commit_msg>Add Comment.<commit_after>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() {
        // Enumをうまく変換する方法がわからなかったので、ひとまずBeanPropertyRowMapperは使わず、ベタに処理を書くことにした。
        // 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;
            }
        });
    }

}
{'fraction_non_alphanumeric': 0.10685249709639953, 'fraction_numerical': 0.0011614401858304297, 'mean_word_length': 3.1456077015643804, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2403270', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1025, 'n_words': 168}