-->
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: DISTINCT_ROOT_ENTITY issue
PostPosted: Fri Mar 11, 2011 4:36 pm 
Newbie

Joined: Thu Jan 20, 2011 4:52 pm
Posts: 2
Hi i have a problem that is happening the following:

Code:
      crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
                crit.setMaxResults(maxResults);
      crit.setFirstResult((page - 1) * maxResults);


it was suposse to return me 50 rows.

but i give me only ten, the question is, my entity is only date attrs, in long format.

and the difference about row1 and row2 maybe is very small, i want to know if hibernate can be rounding my values and not makeking the distinct function very well.

Thx for helps


Top
 Profile  
 
 Post subject: Re: DISTINCT_ROOT_ENTITY issue
PostPosted: Sun Mar 13, 2011 6:06 am 
Newbie

Joined: Sun Mar 13, 2011 5:37 am
Posts: 3
Hi Daniel,

I found two similar issues on StackOverflow that might help:

The problem with DISTINCT_ROOT_ENTITY it's that it removes equal rows. If you happened to use a join method as well, some rows will have different fields although it is the same entity (so this might be effecting the number of rows displayed eventually).

Another reccomendation regarding Criteria#setMaxResults(Integer.MAX_VALUE), suggests to split the retrieving of the data into more queries of X rows each.

And here is an answer regarding the usage of DISTINCT_ROOT_ENTITY with maxResults, which might be more specific:

DISTINCT_ROOT_ENTITY is a Java class, which processes the results of the SQL rows after the SQL is executed. Therefore, when you specify a maxResults, that will be applied as a row limit on the SQL. Once the DISTINCT_ROOT_ENTITY transformer is applied, that may result in less root elements, purely dependent on which root elements happen to come out first in the joined results.

I know this doesn't directly solve your issue, but I hope it'll help figure it out.

Mary


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.