참고 URL:  http://www.programmersought.com/article/72161162674/;jsessionid=FCDF1AB1F47B457B1F87D8CD6706D4DF

 

상황 : 

 1. 게시판 검색 기능 추가 중이 였음

 2. 특정 날짜에 게시된 글 검색 기능 추가 중이 였음. 

 3. 근데 계속 날짜 비교가 되지 않음.

 

문제가 되는 mybatis 코드

		<if test="search.startDate != null and search.startDate != ''">
			<![CDATA[ and date >= #{search.startDate}]]>
		</if>
		<if test="search.endDate != null and search.endDate != ''">
			<![CDATA[ and date <= #{search.endDate}]]>
		</if>

 

search.startDate != ''  , search.endDate != '' 

위의 코드가 문제 였다....;

 

해당 사항을 제거하면 정상적인 비교를 시전한다.

 

결론 

 1. Date/TimeStamp 타입은 무조건 해당 타입과 비교를 시전한다.

 2. 쿼리문 왼쪽에 to_char(date, ~~) 이런짓을 절대 하지말아라(index가 죽어버린다)

 

추가

솔직히 이유가 뭔지 위의 URL을 봐도 모르겠다. 아시는 분 댓글 바람..; 

 

'개발관련 > (과거)메모' 카테고리의 다른 글

Hashed Data RSA 서명할 때 주의사항  (0) 2019.10.01
스프링 빈과 Thread-Safe  (0) 2019.10.01
Integer.ParseInt() vs Integer.valueof()  (1) 2017.05.08
자바 Reflect Class, Method  (0) 2017.04.29
Log4j 2 Manual - Introduction  (0) 2017.04.29
Posted by 동팡