JSP/SEARCH

EmployeeDaoImpl

GAWON 2023. 6. 12. 17:05
package org.joonzis.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import org.joonzis.mybatis.config.DBService;
import org.joonzis.vo.EmployeeVO;




public class EmployeeDaoImpl implements EmployeeDao {
	
	//DAO 객체 생성
	private static EmployeeDaoImpl instace = null;
	public EmployeeDaoImpl() {}
	public static EmployeeDaoImpl GetInstance() {
		if(instace == null) {
			instace = new EmployeeDaoImpl();
		}
		return instace;
	}
	//필드
	private static SqlSession sqlSession = null;
	private synchronized static SqlSession getSqlSession() {
		if(sqlSession == null)
			sqlSession = DBService.getFactory().openSession(false);
		return sqlSession;
	}
	 
	@Override
	public List<EmployeeVO> getALLEmployees() {
		return getSqlSession().selectList("select_all");
	}
	
	@Override
	public List<EmployeeVO> search_dept(int department_id ) {
		return getSqlSession().selectList("search_dept",department_id);
	}

	@Override
	public List<EmployeeVO> getList(Map<String, String> map) {
		return getSqlSession().selectList("getList",map);
	}
		
}