-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is it bug? Criteria.DISTINCT_ROOT_ENTITY & paging
PostPosted: Thu Nov 01, 2007 10:09 am 
Newbie

Joined: Tue Apr 03, 2007 5:42 am
Posts: 13
When Criteria.DISTINCT_ROOT_ENTITY used, hibernate can't paging query?


Code:
Criteria crit = dao.getSession().createCriteria(Ingredient.class);
crit.createAlias("contents", "ct");
crit.createAlias("ct.products", "pd");
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

System.out.println("total:"+crit.list().size());

int offset = 0;
int perPage = 15;
crit.setFirstResult(offset);
crit.setMaxResults(perPage);
List list = crit.list();

System.out.println("list size in page:"+list.size());


this result is .

Code:
total:12615
list size in page : 2


'list size in page' value changed accoring to page no ( offset )

is it hibernate's bug?

note. I must use crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 8:30 pm 
Newbie

Joined: Sun May 06, 2007 11:27 am
Posts: 1
hi slothink,

i've posted a detailed answer to your problem on my blog short time ago:

Solving Hibernate Criteria's "Distinct Root Entity" limitation once and for all - including pagination

hope it helps!

flo ledermann


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.