Hibernate分页
1.使用Criteria
Criteria crit = sess.createCriteria(Cat.class); crit.setFirstResults(100); crit.setMaxResults(50); //当有连表查询时,删除结果中重复的项目 crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); List cats = crit.list();
2.使用NativeSQL
对于MySQL
SQLQuery query = sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, DOG_ID FROM CATS LIMIT 100,50").addEntity(Cat.class); List cats = query.list();
相关推荐
xiaoseyihe 2020-11-16
xiaoseyihe 2020-11-16
世事一场大梦 2020-10-18
jling 2020-10-14
chenyuping 2020-10-06
kyelu 2020-08-03
KAIrving 2020-08-02
xiesheng 2020-08-02
liushall 2020-07-18
shenwenjie 2020-07-07
yunfenglee 2020-07-08
83520298 2020-07-06
Jonderwu 2020-07-05
xiaobater 2020-07-04
范范 2020-06-28
newusb 2020-06-28