This is an automated email from the ASF dual-hosted git repository. ntimofeev pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit d200025c02cc7bf97b638d81a4cca1dd6300fa37 Author: Matt Watson <m...@swarmbox.com> AuthorDate: Tue Feb 7 08:22:36 2023 -0800 CAY-2792 Fix Insertion Order For Reflexive DataObjects --- .../apache/cayenne/access/flush/operation/DefaultDbRowOpSorter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/flush/operation/DefaultDbRowOpSorter.java b/cayenne-server/src/main/java/org/apache/cayenne/access/flush/operation/DefaultDbRowOpSorter.java index 1ad604c54..ed431719e 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/access/flush/operation/DefaultDbRowOpSorter.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/access/flush/operation/DefaultDbRowOpSorter.java @@ -61,14 +61,15 @@ public class DefaultDbRowOpSorter implements DbRowOpSorter { int start = 0; int idx = 0; DbRowOp lastRow = null; - for(DbRowOp row : sortedDbRows) { + for (int i = 0; i < sortedDbRows.size(); i++) { + DbRowOp row = sortedDbRows.get(i); if (row.getEntity() != lastEntity) { - start = idx; if(lastEntity != null && sorter.isReflexive(lastEntity)) { ObjEntity objEntity = resolver.getObjEntity(lastRow.getObject().getObjectId().getEntityName()); List<DbRowOp> reflexiveSublist = sortedDbRows.subList(start, idx); sorter.sortObjectsForEntity(objEntity, reflexiveSublist, lastRow instanceof DeleteDbRowOp); } + start = idx; lastEntity = row.getEntity(); } lastRow = row;