하이버네이트 Criteria 검색 쿼리 골치
select this_.id as y0_ from Post this_ where this_.board_id=?
select this_.id as id1_0_, this_.author as author1_0_, this_.board_id as board7_1_0_, this_.contents as contents1_0_, this_.created as created1_0_, this_.title as title1_0_, this_.updated as updated1_0_
from Post this_
where this_.id in (?, ?, ?, ?, ?, ?) and lcase(this_.title) like ? or lcase(this_.contents) like ?
===============================================
select this_.id as id1_0_, this_.author as author1_0_, this_.board_id as board7_1_0_, this_.contents as contents1_0_, this_.created as created1_0_, this_.title as title1_0_, this_.updated as updated1_0_
from Post this_
where this_.board_id=? and (lcase(this_.title) like ? or lcase(this_.contents) like ?)
================================================
select this_.id as id1_0_, this_.author as author1_0_, this_.board_id as board7_1_0_, this_.contents as contents1_0_, this_.created as created1_0_, this_.title as title1_0_, this_.updated as updated1_0_
from Post this_
where this_.id in
(select this0__.id as y0_ from Post this0__ where this0__.board_id=?)
and (lcase(this_.title) like ? or lcase(this_.contents) like ?)
=================================================
셋 다 똑같네.. 아.. 이런 ㅠ.ㅠ OTL... 뭐야 ㅠ.ㅠ 어떻게 짜야되지. 흠...
(lcase(this_.title) like ? or lcase(this_.contents) like ?)
이 부분이 잘못 됐나? title에 ?가 있거나 contents에 ?가 있는 것들 검색하려는데 분명 테스트 데이터에는 두 개가 나와야 되는데 계속 한 개만 나오네. 흠... 모르겠네... 모르겠어..
=====================
id | title | contents
1 | keesun | toby
2 | toby | toby
3 | toby | keesun
=====================
이 상태에서 서브 쿼리나 in 뒤에 담겨있는 id는 전부 1, 2, 3이라고 치고... titke이 keesun이거나 contents가 keesun이 row를 갖다 달라는 거자나.
그럼 1번 row를 보면 title이 keesun이니까 맞자나. title이 keesun 이자나 contents는 아니고 그럼 일단 하나.
그리고 3번은 contents가 keesun이니까 맞고..
그럼 결과가 2개가 되야 하는데
결과는 1번만 가져오는... 이 상황은 ..;;; 어렵네~