You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2021/09/29 20:37:15 UTC
[ofbiz-framework] branch release18.12 updated: Improved: Improve
velocity of PartyHelper.getPartyName() with the cache
This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release18.12 by this push:
new 59df842 Improved: Improve velocity of PartyHelper.getPartyName() with the cache
59df842 is described below
commit 59df842b832d4294622d7b68bfbf0d8c8e84b518
Author: Nicolas Malin <ni...@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 9605c66..c5f8104 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 {
public 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);
}