I have below scenario
- Got n as minimum number of database required for the transaction.
- Issue
select count(*)
query to find out number of rows satisfying the criteria. - if the result of step 2 is greater than or equal to n, then proceed further or throw exception.
- Fetch actual objects by limit to n in hibernate query.
- do the logic and save the objects.
Is the above more efficient or directly fetching the objects and checking the size of the result set would be more efficient?
I don't need the data if there are not at least 'n' rows satisfying the criteria?
P.S.: Better still is there a way I set like a MinSize() similar to a MaxSize() ?