package org.dbunitng.sample.dao;

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

import org.dbunitng.sample.entity.Dept;
import org.dbunitng.sample.sql.SqlMapClientManager;


import com.ibatis.sqlmap.client.SqlMapClient;

public class DeptDao {

	@SuppressWarnings("unchecked")
	public List<Dept> listAllDept() {
		
		SqlMapClient client = SqlMapClientManager.getSqlMapClient();
		
		try {
			return (List<Dept>)client.queryForList("getDeptList");
		} catch (SQLException e) {
			throw new RuntimeException("SQL関連の例外が発生しました", e);
		}
		
	}
	
	public void addDept(Dept dept) {
		SqlMapClient client = SqlMapClientManager.getSqlMapClient();
		try {
			client.insert("insertDept", dept);
		} catch (SQLException e) {
			throw new RuntimeException("SQL関連の例外が発生しました", e);
		}
	}

}
