Persistence Framework/SQL Mapper-Mybatis 4

동적 쿼리 foreach문

1. 태그 1) collection : 전달받은 인자로 List or Array형태만 가능하다 2) item : 전달받은 인자 값을 alias 명으로 대체 3) open : 구문이 시작될 때 삽입할 문자열 4) close : 구문이 종료될 때 삽입할 문자열 5) index : 반복되는 구문 번호로 0부터 순차적으로 증가한다. 2. 사용 예시 -1 1) controller에서 불러올 때 인자 값 fileno Controller에서 String[] fileno = request.getParameterValues("fileno"); boardDetailsDao.insertBoard(boardInfo, filelist, fileno); 2) DaoImpl에서 hashmap으로 if (fileno != null)..

마이바티스 설정 파일(mybatis-config.xml)

1. 마이바티스 설정파일의 역할: mabatis-config.xml의 역할을 알기위해서는 JDBC 코드와 비교해보면 이해하기 편하다. JDBC에서 아래 코드에 해당하는 부분을 Mybatis에서는 mybatis-config.xml에 설정하는 것이다. public bbsDAO() { try { String dbURL = "jdbc:mysql://localhost:3306/BBS?autoReconnect=true&useSSL=false"; String dbID = "root"; String dbPassword = "root"; Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(dbURL, dbID, dbPassword); } ..