Actually in this case probably not. The query uses the cache and the result set is likely small so filtering by date in memory should be more efficient, you can't use the cache and include a date condition because the cached result would never be hit again. There's also a bug in the date condition code that prevents it from caching correctly (it doesn't implement equals() correctly which causes false hits).
A potentially cool feature that just occurred to me would be to implement a list or iterator wrapper that would filter by date as the results are iterated over, that would prevent the need to iterate over the results twice (once for the date filter and again to actually work with the values). The list or iterator could be constructed with an EntityCondition parameter. Regards Scott On 16/03/2013, at 1:38 AM, Adrian Crum wrote: > This will work, but it would have been best to include the date range filter > in the entity condition. > > -Adrian > > On 3/15/2013 11:16 AM, paulfoxwor...@apache.org wrote: >> Author: paulfoxworthy >> Date: Fri Mar 15 11:16:38 2013 >> New Revision: 1456897 >> >> URL: http://svn.apache.org/r1456897 >> Log: >> Exclude expired product category members from tax calc (OFBIZ-4940) >> >> Modified: >> >> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java >> >> Modified: >> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=1456897&r1=1456896&r2=1456897&view=diff >> ============================================================================== >> --- >> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java >> (original) >> +++ >> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java >> Fri Mar 15 11:16:38 2013 >> @@ -330,7 +330,7 @@ public class TaxAuthorityServices { >> } else { >> productIdCond = >> EntityCondition.makeCondition("productId", EntityOperator.EQUALS, >> product.getString("productId")); >> } >> - List<GenericValue> pcmList = >> delegator.findList("ProductCategoryMember", productIdCond, >> UtilMisc.toSet("productCategoryId"), null, null, true); >> + List<GenericValue> pcmList = >> delegator.findList("ProductCategoryMember", productIdCond, >> UtilMisc.toSet("productCategoryId", "fromDate", "thruDate"), null, null, >> true); >> pcmList = EntityUtil.filterByDate(pcmList, true); >> for(GenericValue pcm : pcmList) { >> >> productCategoryIdSet.add(pcm.getString("productCategoryId")); >> >> >