bynothing / hibernate-generic-dao

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

Getting result count and filter like #55

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have two questions about the API, I was not sure where to ask them except 
here. Any help will be greatly appreciated.

1.) How can I get the count of result set before applying pagination or 
sorts. I tried  method getMaxResults() in Search class but it returned -1.

2.) For filter ilike or like, is there a way to specify the mode (that is - 
anywhere in the string, starts with or ends with). At the moment I am using 
% sign with search string (postgres db), which makes it database dependent.

Thanks,
-jas
p.s. - great implementation, very easy to use API!

Original issue reported on code.google.com by j3gre...@gmail.com on 26 Nov 2009 at 8:48

GoogleCodeExporter commented 8 years ago
I found answer to my first question. Had missed the count() method in 
GenericDAO class 
earlier.

Any suggestion for second question.

Thanks.
-jas

Original comment by j3gre...@gmail.com on 26 Nov 2009 at 10:26

GoogleCodeExporter commented 8 years ago
As for the first, there is also a searchAndCount method that returns both the 
results 
of the search and the total count (same as count method) at once. Depending on 
your situation, this might also be helpful.

And for the second, we're still relying on programmers to use %'s and ?'s. 
Starts with 
and ends with are something planned for the future. But I was under the 
impression 
that % is an SQL standard, not DB dependent. If I'm wrong on this please let me 
know.

Also, the best place for a question like this is 
http://groups.google.com/group/java-
generic-dao. In fact, please repost your question there and I'll copy my answer 
over 
as well so that people with similar questions will be able to see the thread 
there in 
the future. And thanks for using the framework! I hope you continue to have 
success 
with it. Be sure to let us know if you have any other suggestions for 
improvement.

David W.

Original comment by dwolvert on 28 Nov 2009 at 2:53

GoogleCodeExporter commented 8 years ago
Thank you for the quick response.

I have reposted the question on java-generic-dao group.

-jas

Original comment by j3gre...@gmail.com on 4 Dec 2009 at 1:55

GoogleCodeExporter commented 8 years ago

Original comment by dwolvert on 4 Dec 2009 at 3:26