You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2026/07/24 08:13:09 UTC
(ofbiz-framework) 02/02: Fixed: Never let entity import move a SequenceValueItem counter backward (OFBIZ-5259)
This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit c7853869aa35989e96fd6708117e5548c66dcc6c
Author: Mridul Pathak <mr...@hotwaxsystems.com>
AuthorDate: Thu Jul 23 20:30:51 2026 +0530
Fixed: Never let entity import move a SequenceValueItem counter backward (OFBIZ-5259)
EntitySaxReader now prevents re-import of stale SequenceValueItem rows from
regressing sequence counters. When an import would move a SequenceValueItem's
seqId backward (detected by comparing incoming seqId to current database
value), the import is skipped and a warning is logged.
Behavior change applies only to the SequenceValueItem entity -- all other
entities are unaffected. DELETE actions are excluded from the guard, and so
are checkDataOnly (verify) runs, which still need to surface the would-be
mismatch instead of silently skipping over it.
---
.../org/apache/ofbiz/entity/util/EntitySaxReader.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java
index 740c91cc87..ee8b08fdc7 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java
@@ -225,6 +225,19 @@ public class EntitySaxReader extends DefaultHandler {
this.currentAction = action;
}
+ private boolean isSequenceValueItemRegression(GenericValue value) throws GenericEntityException {
+ if (!"SequenceValueItem".equals(value.getEntityName())) {
+ return false;
+ }
+ GenericValue existing = delegator.findOne("SequenceValueItem", false, "seqName", value.get("seqName"));
+ if (existing == null) {
+ return false;
+ }
+ Long incomingSeqId = value.getLong("seqId");
+ Long existingSeqId = existing.getLong("seqId");
+ return incomingSeqId != null && existingSeqId != null && incomingSeqId < existingSeqId;
+ }
+
/**
* Parse long.
* @param content the content
@@ -485,6 +498,12 @@ public class EntitySaxReader extends DefaultHandler {
skip = true;
}
}
+ if (!skip && !this.checkDataOnly && Action.DELETE != currentAction && isSequenceValueItemRegression(currentValue)) {
+ skip = true;
+ Debug.logWarning("Skipping import of " + currentValue.getEntityName() + " [" + currentValue.get("seqName")
+ + "]: imported seqId=" + currentValue.getLong("seqId")
+ + " would move the sequence counter backward, keeping the current higher value", MODULE);
+ }
if (!skip) {
if (this.useTryInsertMethod && !this.checkDataOnly) {
if (Action.DELETE == currentAction) {