전체 글 105

[Mybatis] result type이 HashMap일 때 Null 처리

Mybatis에서 result 타입은 보통 VO를 많이 만들어서 지정해준다. 하지만 그게 안될 때 (VO가 너무 많아서 포기ㅎ;;) result type 을 보통은 HashMap으로 구성하게 되는데 문제는 Null이 결과인 컬럼은 Map의 키에 저장되지 않는다;; *******if ( data == null ) return ; else map.put("col_name", data); ****** 이런 느낌 덕분에 각 결과맵의 size가 달라질수도 잇는 재미잇는 상황;; import 할때도 밀려들어갈 수 잇다. 이럴 땐 Mybatis-config.xml 파일에 다음값을 추가해주면 된다. *mybatis-config.xml 내 케이스에는 이 설정파일 자체가 없엇다. 어디서 적용하나 햇더니 * Applicat..

Develope/DataBase 2017.11.14

[Mybatis/MariaDB] foreach 구문을 이용해서 Insert 대량 삽입하기

이 키워드로 들어오는 분들이 많아서 추가글 링크도 남긴다. foreach 처음 사용해봣을때의 글이니 어색하다.. 추가작업내용 : [MyBatis] 동적 쿼리문 만들기 (List insert, foreach)https://vivi-world.tistory.com/50 [MyBatis] 객체 (VO, DTO) 안의 리스트를 사용해서 인서트 작업하기https://vivi-world.tistory.com/40 * 결론 INSERT INTO collect_data_result ( collect_date, collect_time, table_name, target_table, building_id , flag, type, execute_time, count, remark ) VALUES ("${item.collec..

Develope/DataBase 2017.11.10

[Mysql] Select할 때 String 을 Date로 표현하기, 포맷 변환

ex)데이터 : varchar (8) 20170316 변환하고 싶은 형태 2017-03-16 DATE_FORMAT(STR_TO_DATE(date, '%Y%m%d'),'%Y-%m-%d ') *DATE_FORMAT ( Date, format ) Date타입의 값을 format에 지정한대로 출력해준다. * STR_TO_DATE( string, format )The STR_TO_DATE() converts the str string into a date value based on the fmt format string. The STR_TO_DATE() function may return a DATE , TIME, or DATETIME value based on the input and format strings..

Develope/DataBase 2017.11.02