cjmcn-sh / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
2 stars 1 forks source link

[REQ] Start Result and End Result #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In my application, client side often ask data to the server based on a First 
Result and a Last 
Result. It's different from paging that you have a fixed max results.

Would be nice to have this feature on your Search object.

Nowadays I extend your Search class and add this method:

public Search setLastResult(int lastResult)
{
    if (this.getFirstResult() == -1)
    {
        throw new IllegalArgumentException("First Result must be set!");
    }
    if(lastResult < this.getFirstResult())
    {
        throw new IllegalArgumentException("Last Result must be greater than First Result!");
    }
    this.setMaxResults(lastResult - this.getFirstResult() + 1);
    return this;
}

If it's against your patterns, please ignore.

Thanks.

Original issue reported on code.google.com by terciofi...@gmail.com on 29 Jun 2009 at 11:00

GoogleCodeExporter commented 9 years ago
I've decided just to stick with first result, max results and page.

Hibernate uses only first result and max results. I think page is something that
comes in very handy and is used a lot.

I don't think that last result is nearly as common (I could be wrong). 
Terciofilho's
work-around seems to be working well for him, and I don't want to add more 
complexity
to the framework.

Original comment by dwolvert on 10 Sep 2009 at 12:11