public class DepartmentDAO { private SqlMapClientTemplate sqlMap; public DepartmentDAO(SqlMapClientTemplate sqlMap){ this.sqlMap = sqlMap; } public void insertDepartment(DepartmentDTO dto){ sqlMap.insert("insertDepartment", dto); System.out.println("1개의 부서가 삽입되었습니다."+dto); } public int updateDepartment(DepartmentDTO dto){ int cnt = sqlMap.update("updateDepartment", dto); return cnt; } public int deleteDepartmentById(String departmentId){ int cnt = sqlMap.delete("deleteDepartment", departmentId); return cnt;
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((departmentId == null) ? 0 : departmentId.hashCode()); result = prime * result + ((departmentName == null) ? 0 : departmentName.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DepartmentDTO other = (DepartmentDTO) obj; if (departmentId == null) { if (other.departmentId != null) return false; } else if (!departmentId.equals(other.departmentId)) return false; if (departmentName == null) { if (other.departmentName != null) return false; } else if (!departmentName.equals(other.departmentName)) return false; if (location == null) { if (other.location != null) return false; } else if (!location.equals(other.location)) return false; return true; }
public class TestDepartment { public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("dept/config/spring.xml"); DepartmentDAO dao = (DepartmentDAO)ctx.getBean("departmentDAO"); DepartmentDTO ddto = new DepartmentDTO("D0007","개발부","울산지점");
public class DepartmentDAO { private SqlMapClientTemplate sqlMap; public DepartmentDAO(SqlMapClientTemplate sqlMap){ this.sqlMap = sqlMap; } public void insertDepartment(DepartmentDTO dto){ System.out.println(sqlMap); } public int updateDepartment(DepartmentDTO dto){ return 0;
} public int deleteDepartmentById(String departmentId){ return 0;
} public DepartmentDTO selectDepartmentById(String departmentId){ return null;
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((departmentId == null) ? 0 : departmentId.hashCode()); result = prime * result + ((departmentName == null) ? 0 : departmentName.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DepartmentDTO other = (DepartmentDTO) obj; if (departmentId == null) { if (other.departmentId != null) return false; } else if (!departmentId.equals(other.departmentId)) return false; if (departmentName == null) { if (other.departmentName != null) return false; } else if (!departmentName.equals(other.departmentName)) return false; if (location == null) { if (other.location != null) return false; } else if (!location.equals(other.location)) return false; return true; }