| 양쪽 이전 판
이전 판
다음 판
 | 
                    이전 판
 | 
                
                        
                
                    wiki:spring:mybatis [2020/03/24 22:15] dhan                  | 
                
                    wiki:spring:mybatis [2023/01/13 18:44] (현재)                   | 
            
        
| ===== mapper.xml 예시 ===== | ===== mapper.xml 예시 ===== | 
| SELECT 예시 | SELECT 예시 | 
| <code sql> | <code xml> | 
|     <select id="boardList" resultType="BoardDto" useCache="true"> |     <select id="boardList" resultType="BoardDto" useCache="true"> | 
|         select * from tbl_board order by pos asc |         select * from tbl_board order by pos asc | 
 |  | 
| UPDATE 예시 | UPDATE 예시 | 
| <code> | <code xml> | 
|     <update id="readCount" parameterType="int"> |     <update id="readCount" parameterType="int"> | 
|         update tbl_board set count = count + 1 where seq = #{seq} |         update tbl_board set count = count + 1 where seq = #{seq} | 
 |  | 
| DELETE 예시 | DELETE 예시 | 
| <code sql> | <code xml> | 
|     <delete id="deleteBoard" parameterType="map"> |     <delete id="deleteBoard" parameterType="map"> | 
|         delete from tbl_board where seq=#{seq} and password=#{storPass} |         delete from tbl_board where seq=#{seq} and password=#{storPass} | 
| </code> | </code> | 
 |  | 
| [[http://www.mybatis.org/mybatis-3/ko/sqlmap-xml.html|Mapper XML 파일]] | [[http://www.mybatis.org/mybatis-3/ko/sqlmap-xml.html|Mapper XML 파일]] \\  | 
|   | [[https://taetaetae.github.io/2017/04/04/mybatis-useGeneratedKeys/|mybatis insert/update 쿼리실행후 결과 가져오기]] \\ | 
 |  | 
| [[https://taetaetae.github.io/2017/04/04/mybatis-useGeneratedKeys/|mybatis insert/update 쿼리실행후 결과 가져오기]] | ===== 동적 쿼리 =====  | 
|   | [[http://blog.naver.com/roropoly1/221184569655|myBatis parameterType="String" 일 때 동적쿼리에서 사용]] | 
 |  | 
|   | ===== 배치(Batch) 입력/수정 ===== | 
|   | [[https://vivi-world.tistory.com/13|[Mybatis/MariaDB] foreach 구문을 이용해서 Insert 대량 삽입하기]] \\ | 
|   | [[https://baejangho.com/entry/Java-Mybatis-Batch-Insert|[Java / Mybatis] 일괄(Batch) 입력/수정(Insert/Update)]] \\ | 
 |  | 
| ===== Mybatis에서 Null체크 (ibatis와 비교) ===== | ===== choose =====  | 
|   | [[https://kmhan.tistory.com/43|[Mybatis] if else문 대체하는 방법]] \\  | 
|   |   | 
|   | ===== Null체크 (ibatis와 비교) ===== | 
| >Mybatis | >Mybatis | 
| <code xml> | <code xml> | 
|   </isNotNull> |   </isNotNull> | 
| </code> | </code> | 
| [[https://hellogk.tistory.com/100|mybatis와 ibatis별 동적태그 비교문 알아보도록 하자]] | [[https://hellogk.tistory.com/100|mybatis와 ibatis별 동적태그 비교문 알아보도록 하자]] \\  | 
|   | [[https://web-obj.tistory.com/246|ibatis to mybatis 전자정부프레임워크]] \\  | 
|   | [[https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte2:psl:dataaccess:mybatisguide|MyBatis 적용 가이드]] \\ | 
 |  | 
| ===== Mybatis Tip ===== |   | 
|   |   | 
|   |   | 
|   | ===== ResultHandler =====  | 
|   | [[https://kongeebol.tistory.com/2|[Excel POI] Mybatis ResultHandler 사용하여 대용량 데이터 추출]] \\  | 
|   |   | 
|   | ===== ResultType & ResultMap =====  | 
|   | [[https://dorongdogfoot.tistory.com/124|[MyBatis] resultMap 과 resultType (resultClass) 의 차이점]] \\  | 
|   |   | 
|   | ===== Test =====  | 
|   | [[https://sinpk.tistory.com/entry/Mybatis-if-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%B9%84%EA%B5%90|Mybatis if 문자열 비교]] \\  | 
|   | [[https://madnix.tistory.com/entry/%EB%A7%88%EC%9D%B4%EB%B0%94%ED%8B%B0%EC%8A%A4%EB%8A%94-%EB%8F%99%EC%A0%81-%EC%BF%BC%EB%A6%AC%EB%AC%B8-%EC%83%9D%EC%84%B1%EC%97%90-%EC%82%AC%EC%9A%A9%EB%90%98%EB%8A%94-if-%EA%B5%AC%EC%84%B1-%EC%9A%94%EC%86%8C%EB%A5%BC-%EC%A0%9C%EA%B3%B5|마이바티스는 동적 쿼리문 생성에 사용되는 <if /> 구성 요소를 제공...]]  | 
|   |   | 
|   | ===== Tip ===== | 
|   * DBCP 기본값 |   * DBCP 기본값 | 
|     <property name="initialSize" value="0"/> |     <property name="initialSize" value="0"/> | 
| >   주로 발생하는 상황은 오류가 발생한 연결이나, 사용되지 않고 오래된 연결은 풀에서 제거됩니다. 이 경우 풀내의 연결의 갯수가 minIdle 이하로 떨어지면 새로 생성해서 minIdle 갯수에 맞추게 됩니다. | >   주로 발생하는 상황은 오류가 발생한 연결이나, 사용되지 않고 오래된 연결은 풀에서 제거됩니다. 이 경우 풀내의 연결의 갯수가 minIdle 이하로 떨어지면 새로 생성해서 minIdle 갯수에 맞추게 됩니다. | 
| > maxWait - 풀에 사용 가능할 연결이 없을때 대기하는 최대 시간을 밀리초 단위로 나타냅니다. 이 대기시간후에도 사용 가능한 연결이 없으면 예외를 발생합니다. -1은 무한대기를 나타냅니다. 기본값은 -1입니다. | > maxWait - 풀에 사용 가능할 연결이 없을때 대기하는 최대 시간을 밀리초 단위로 나타냅니다. 이 대기시간후에도 사용 가능한 연결이 없으면 예외를 발생합니다. -1은 무한대기를 나타냅니다. 기본값은 -1입니다. | 
|   |  | 
|   | ===== Troubleshooting ===== | 
|   | DAO에서 보낸 VO가 SQL에서 값이 사라져 버릴 경우 | 
|   | > 긴장하지 말고 pom.xml에서 mybatis, mybatis-spring 버전 업데이트 하면 해결이 됩니다.  | 
|   |  | 
|   |  | 
|   |  | 
|   |  | 
|   |  | 
|   |  | 
| ===== Ref ===== | ===== Ref ===== | 
|   |   * [[https://offbyone.tistory.com/161|전자정부 표준프레임워크 - dataSource (DBCP) 설정하기]] | 
|   * [[http://blog.naver.com/roropoly1/221184569655|myBatis parameterType="String" 일 때 동적쿼리에서 사용]] |   * [[http://blog.naver.com/roropoly1/221184569655|myBatis parameterType="String" 일 때 동적쿼리에서 사용]] | 
|   * [[출처: https://offbyone.tistory.com/161 [쉬고 싶은 개발자]|전자정부 표준프레임워크 - dataSource (DBCP) 설정하기]] |   * [[https://jsonobject.tistory.com/240|MyBatis, Dynamic SQL 기본식 알아보기]] | 
 |  | 
| {{tag>주레피 eleven mybatis}} | {{tag>주레피 eleven mybatis}} |