Hibernate pagination mechanism

后端 未结 3 1591
礼貌的吻别
礼貌的吻别 2020-12-14 11:26

I am trying to use Hibernate pagination for my query (PostgreSQL )

I set setFirstResult(0), setMaxResults(20) for my SQL query. My code is

3条回答
  •  感情败类
    2020-12-14 12:25

    I am using in query and in hibernate call back. both are working as expected. Hibernate Query executes for results in between First and Max size given. Here Seems like you passed SQL not HQL to query. if yes it shouldn't work.

    -- See my code here.

            Query query = this.getSession().createQuery("FROM QueryType");
            query.setFirstResult(0);
            query.setMaxResults(20);
            List toDelete = query.list();
    

    and in log:

    select * from ( select -- ALL column names. (dont want to share here.) from MY_TBL_NAME querytype0_ ) where rownum <= ?

提交回复
热议问题