-->
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.  [ 6 posts ] 
Author Message
 Post subject: criteria.scroll returns duplicates, criteria.list does not!
PostPosted: Wed Feb 28, 2007 6:49 am 
Newbie

Joined: Wed Feb 28, 2007 5:10 am
Posts: 3
Hibernate 3.2.2 and 3.1.3

I have a simple query to load Cars based on Classification, (many to many relationship)

I have applied Criteria.DISTINCT_ROOT_ENTITY to prevent duplicates that can arise.

Code:
Criteria c = session.createCriteria(Car.class)
         .addOrder(Order.asc("id"))           
                .createCriteria("classifiedAs")
                    .add(Restrictions.or(
                        Restrictions.eq("name", "CLASS0"), Restrictions.eq("name", "CLASS1") ));
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

List rs = c.list();
for (Object object : rs)
{
System.out.println("Car:" + object);
}



this gives the following output,
Car:{id:32769, name:Car1}
Car:{id:32770, name:Car2}

So far so good, however when I use scroll instead of list
Code:
ScrollableResults rs = c.scroll();
while( rs.next() )
{
   System.out.println("Car:"+  rs.get(0));
}


I get duplicates
Car:{id:32769, name:Car1}
Car:{id:32769, name:Car1}
Car:{id:32770, name:Car2}
Car:{id:32770, name:Car2}

I have looked at the docs/forums/JIRA and there is a lot info but no one seems to be able to clarify if this is a bug or not.

To me it's a bug as criteria.list and criteria.scroll should return the same results. It looks like criteria.scroll doesn't obey the DISTINCT_ROOT_ENTITY contract.

Can someone point me to the appropriate doc/faq to clarify this?

Thanks,
Conor.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 05, 2007 6:12 pm 
Newbie

Joined: Thu Jul 05, 2007 5:13 pm
Posts: 1
I got the same issue. Any solution for this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 10:56 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
hello

any solutions to this problem??

regards angela


Top
 Profile  
 
 Post subject: Re: criteria.scroll returns duplicates, criteria.list does not!
PostPosted: Sun Jun 28, 2009 1:12 pm 
Newbie

Joined: Sun Jun 28, 2009 12:58 pm
Posts: 1
Hello,

I also have the same issue using DetachedCriteria.

When I execute the query with list() I get the correct number of rows (no duplicate of root entity) but when I use scroll() I do get the duplicates (for the exact same query or instance of DetachedCriteria).

I use Hibernate 3.2.1 GA with Oracle 11g.

Please Help!

Zohar


Top
 Profile  
 
 Post subject: Re: criteria.scroll returns duplicates, criteria.list does not!
PostPosted: Sun Feb 07, 2010 1:09 am 
Newbie

Joined: Tue Mar 15, 2005 1:38 pm
Posts: 11
I'm also running into this exact issue. Did anyone ever get to the bottom of this?


Top
 Profile  
 
 Post subject: Re: criteria.scroll returns duplicates, criteria.list does not!
PostPosted: Sat Aug 24, 2013 5:58 pm 
Newbie

Joined: Sat Aug 24, 2013 5:57 pm
Posts: 1
Well, this thread is 6 years old. Has anybody found solution for this problem?


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