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; }
public class CollectionDTO { private List myList; private String[] names; private Set mySet; private Map myMap; private Properties myProps; public List getMyList() { return myList; }
public void setMyList(List myList) { this.myList = myList; }
public String[] getNames() { return names; }
public void setNames(String[] names) { this.names = names; }
public Set getMySet() { return mySet; }
public void setMySet(Set mySet) { this.mySet = mySet; }
public Map getMyMap() { return myMap; }
public void setMyMap(Map myMap) { this.myMap = myMap; }
public Properties getMyProps() { return myProps; }
public void setMyProps(Properties myProps) { this.myProps = myProps; }
}
package di.dto;
public class DirectorDTO { private String directorId; private String name; private int age; public DirectorDTO() { super(); } public DirectorDTO(String directorId, String name, int age) { super(); this.directorId = directorId; this.name = name; this.age = age; }
public String getDirectorId() { return directorId; } public void setDirectorId(String directorId) { this.directorId = directorId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "DirectorDTO [directorId=" + directorId + ", name=" + name + ", age=" + age + "]"; }