Hi Hibernators,
I'm not sure if this is hibernate's bug or my mistake :-(
Pls see next:
HQL:
Code:
select distinct p from Product as p left outer join p.keywords as keyword where 1=1 and ( keyword.value like :keyword or p.name like :prodNameKeyword )
Database: MSSQL2000 sp4
JDBC driver: JTDS version 1.2
Hibernate: version 3.2.3ga and 3.2.5 ga
For above situction, when I set fist reslut and fetch size, this cannot work,
Code:
Code:
query.setFirstResult(0);
query.setFetchSize(10);
The SQL generated by Hibernate:
Code:
select
distinct product0_.PROD_SYS_ID as PROD1_24_,
product0_.VERSION_NUM as VERSION2_24_,
product0_.NAME as NAME24_,
product0_.MODEL as MODEL24_,
product0_.SPEC as SPEC24_,
product0_.CLICK_TIMES as CLICK6_24_,
product0_.PRICE as PRICE24_,
product0_.CIQ_CD as CIQ8_24_,
product0_.PROD_ADDR as PROD9_24_,
product0_.PACKAGE as PACKAGE24_,
product0_.MIN_ORDER_NUM as MIN11_24_,
product0_.TRANSPORT_METHOD as TRANSPORT12_24_,
product0_.PROD_DESC as PROD13_24_,
product0_.PROD_ST_CD as PROD14_24_,
product0_.REJ_RSN as REJ15_24_,
product0_.REJ_SUGGESTION as REJ16_24_,
product0_.PAGE_DISPLAY_IND as PAGE17_24_,
product0_.CREATE_USER_ID as CREATE18_24_,
product0_.CREATE_DTTM as CREATE19_24_,
product0_.LAST_UPD_USER_ID as LAST20_24_,
product0_.LAST_UPD_DTTM as LAST21_24_,
product0_.CATEGORY_SYS_ID as CATEGORY22_24_,
product0_.USER_SYS_ID as USER23_24_
from
PRODUCT product0_
left outer join
L_PROD_KEYWORD keywords2_
on product0_.PROD_SYS_ID=keywords2_.PROD_SYS_ID
left outer join
KEYWORD keyword3_
on keywords2_.KEYWORD_SYS_ID=keyword3_.KEYWORD_SYS_ID
where
1=1
and (
keyword3_.VALUE like ?
or product0_.NAME like ?
)
order by
product0_.CREATE_DTTM desc
I very appreciate you if you can give me any suggestion!