Hello,
This is my first post to the forum, so all my appologies if I make any mistake in the form of the post.
We are now working with DetachedCriterias to get a list of objects in the database, just like that :
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(Sample.class)
.add(Restrictions.ge("validityDate", new Date()))
.add(Restrictions.eq("sampleValidated", true))
.addOrder(Property.forName("sampleValidated").asc())
.addOrder(Property.forName("validityDate").asc())
.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE);
List list=template.findByCriteria(criteria);
It's working great, and the transformer removes the duplicate items returned by the criteria search (that we still don't know why there are duplicates but anyway, it does) perfectly (as we expected).
Now, we are changing it a little, we want to get the results 4 to 8. Here is what we do :
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(Sample.class)
.add(Restrictions.ge("validityDate", new Date()))
.add(Restrictions.eq("sampleValidated", true))
.addOrder(Property.forName("sampleValidated").asc())
.addOrder(Property.forName("validityDate").asc())
.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE);
List list=template.findByCriteria(criteria,4,4);
The problem is that the list now contains only 1 item, where the previous list contained 20+ items. In fact, we think that the findByCriteria(criteria,int,int) is scaling the result before it removes the duplicate. That's a very big problem. We don't know how to do except like that. We were expecting the findByCriteria to scale after it did all the criteria things.
Are we wrong thinking that way ? If so, can someone kindlt indicate us where we are wrong, and how we can fix this ?
Thanks a lot
Fred