[
https://issues.apache.org/jira/browse/OFBIZ-9893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16495398#comment-16495398 ]
Gareth Carter commented on OFBIZ-9893:
--------------------------------------
Hi Nicolas
It might help with some examples as to why I created it...
{code}
from("Enumeration").where("enumTypeId", "someType").getFieldMap("enumCode", "description");
from("Product").where(ecb.build()).getFieldMap("productId", "internalName");
EntityQuery.use(delegator)
.from("PartyAttribute")
.where(ecbAttr.build())
.getFieldMap("attrName", "attrValue")
{code}
In some cases, we (at Stannah) wanted to put the above entities into maps either for caching purposes or to collect all data (eg *Attribute entities). The method just removes the boiler plate code of converting GenericValue to Map entries. It will still work with a filterByDate() but so far we have not used it for any entity with from/thru date fields.
I have no issue with changing to queryFieldMap if we want to be consistent with other methods names.
We could move the implementation to EntityUtil but I would keep a method in EntityQuery too. In your example, you have written slightly more code which I feel is unnecessary.
As for forEach, yes it could be done in groovy and now in java 8 you can do it on anything object that implements Iterable......however doing queryList().forEach has a performance impact. You will be loading all data in your query into memory before looping with forEach. The forEach implements in EntityQuery will only load 1 GenericValue object at a time with will work better with large queries
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)