This is an automated email from the ASF dual-hosted git repository. nmalin pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push: new 2d14be3 Improved: Improve velocity of PartyHelper.getPartyName() with the cache 2d14be3 is described below commit 2d14be3c3dbc639fb90be3f0d0a2bb6985bbb7b7 Author: Nicolas Malin <nicolas.ma...@nereide.fr> AuthorDate: Wed Sep 29 21:34:33 2021 +0200 Improved: Improve velocity of PartyHelper.getPartyName() with the cache The class PartyHelper is massively used to resolve the name of a party without know is type. <field name="organizationPartyId" title="${uiLabelMap.ProductOrganization}"> <display description="${groovy: org.apache.ofbiz.party.party.PartyHelper.getPartyName(delegator, organizationPartyId, true);} [${organizationPartyId}]"/> </field> A party name have few change over time, or the PartyHelper.getPartyName function call the database at each call. On huge screen, we distinctly clearly the database latency. So for a cold data, no reason to didn't use the cache. --- .../src/main/java/org/apache/ofbiz/party/party/PartyHelper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java index 7373adf..2bbc852 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java @@ -30,7 +30,7 @@ import org.apache.ofbiz.entity.util.EntityQuery; /** * PartyHelper */ -public class PartyHelper { +public final class PartyHelper { private static final String MODULE = PartyHelper.class.getName(); @@ -43,7 +43,10 @@ public class PartyHelper { public static String getPartyName(Delegator delegator, String partyId, boolean lastNameFirst) { GenericValue partyObject = null; try { - partyObject = EntityQuery.use(delegator).from("PartyNameView").where("partyId", partyId).queryOne(); + partyObject = EntityQuery.use(delegator).from("PartyNameView") + .where("partyId", partyId) + .cache() + .queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error finding PartyNameView in getPartyName", MODULE); }