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 2c1dd14737 Improved: Optimization on removeJob service (OFBIZ-13182)
2c1dd14737 is described below

commit 2c1dd1473791be5b9eca9588cd7bb8db4f6cbea2
Author: Nicolas Malin <nicolas.ma...@nereide.fr>
AuthorDate: Wed Nov 20 09:53:30 2024 +0100

    Improved: Optimization on removeJob service (OFBIZ-13182)
    
    On removeJob service when we'll remove a job sandbox, we also delete other 
element linked (RecurrenceInfo and RuntimeData).
    
    Before their remove we control that no other job are connected to them, but 
currently we resolve the list and ensure that it empty.
    
    To be fast, we just ask the database through a count and ensure that is 
zero.
---
 .../src/main/java/org/apache/ofbiz/service/job/JobUtil.java  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/framework/service/src/main/java/org/apache/ofbiz/service/job/JobUtil.java 
b/framework/service/src/main/java/org/apache/ofbiz/service/job/JobUtil.java
index 7f8b94e930..ca5e973931 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/job/JobUtil.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/job/JobUtil.java
@@ -18,13 +18,13 @@
  
*******************************************************************************/
 package org.apache.ofbiz.service.job;
 
-import java.util.List;
 import javax.transaction.Transaction;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.entity.transaction.GenericTransactionException;
 import org.apache.ofbiz.entity.transaction.TransactionUtil;
+import org.apache.ofbiz.entity.util.EntityQuery;
 
 public final class JobUtil {
 
@@ -43,16 +43,18 @@ public final class JobUtil {
             jobValue.remove();
             GenericValue relatedValue = 
jobValue.getRelatedOne("RecurrenceInfo", false);
             if (relatedValue != null) {
-                List<GenericValue> valueList = 
relatedValue.getRelated("JobSandbox", null, null, false);
-                if (valueList.isEmpty()) {
+                if (EntityQuery.use(jobValue.getDelegator()).from("JobSandbox")
+                        .where("recurrenceInfoId", 
relatedValue.get("recurrenceInfoId"))
+                        .queryCount() == 0) {
                     relatedValue.remove();
                     relatedValue.removeRelated("RecurrenceRule");
                 }
             }
             relatedValue = jobValue.getRelatedOne("RuntimeData", false);
             if (relatedValue != null) {
-                List<GenericValue> valueList = 
relatedValue.getRelated("JobSandbox", null, null, false);
-                if (valueList.isEmpty()) {
+                if (EntityQuery.use(jobValue.getDelegator()).from("JobSandbox")
+                        .where("runtimeDataId", 
relatedValue.get("runtimeDataId"))
+                        .queryCount() == 0) {
                     relatedValue.remove();
                 }
             }

Reply via email to