-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: setFirstResult(0) and setFetchSize(10) didn't work!
PostPosted: Tue Dec 18, 2007 10:54 am 
Newbie

Joined: Wed Jan 26, 2005 5:47 am
Posts: 2
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!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 11:39 am 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
are you looking for setting the fetch size, or limiting the number of results returned, in the latter case, you should say
Quote:
query.setMaxResults(10);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 12:08 pm 
Newbie

Joined: Wed Jan 26, 2005 5:47 am
Posts: 2
plasmafire wrote:
are you looking for setting the fetch size, or limiting the number of results returned, in the latter case, you should say
Quote:
query.setMaxResults(10);


oops.... It's my fault.

After correct my code, it's works well. Thanks so much plasmafire!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 12:21 pm 
Beginner
Beginner

Joined: Wed May 16, 2007 7:12 am
Posts: 41
Location: London
Don't worry about it. Glad to be of help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.