You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2020/10/01 08:16:55 UTC
[cayenne] branch STABLE-4.1 updated: CAY-2679 Unstable ordering of
relationships in the .map.xml file
This is an automated email from the ASF dual-hosted git repository.
ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/STABLE-4.1 by this push:
new e1b3de3 CAY-2679 Unstable ordering of relationships in the .map.xml file
e1b3de3 is described below
commit e1b3de34de5b4230f03068e2a14fd4ce74e61b84
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Wed Sep 30 18:20:47 2020 +0300
CAY-2679 Unstable ordering of relationships in the .map.xml file
---
RELEASE-NOTES.txt | 1 +
cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 0a121b4..1ffcae3 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -15,6 +15,7 @@ Date:
Bug Fixes:
CAY-2670 CommitLog does not include FKs for deleted objects with one-way relationships
+CAY-2679 Unstable ordering of relationships in the .map.xml file
----------------------------------
Release: 4.1
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java b/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
index 9bebad8..7ea1521 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
@@ -37,6 +37,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@@ -335,7 +336,9 @@ public class DataMap implements Serializable, ConfigurationNode, XMLSerializable
// stores relationships for the map of entities
private void encodeDbRelationshipsAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
for (Entity entity : new TreeMap<>(getDbEntityMap()).values()) {
- entity.getRelationships().stream().filter(r -> !r.isRuntime())
+ entity.getRelationships().stream()
+ .filter(r -> !r.isRuntime())
+ .sorted(Comparator.comparing(Relationship::getName))
.forEach(r -> r.encodeAsXML(encoder, delegate));
}
}
@@ -343,7 +346,9 @@ public class DataMap implements Serializable, ConfigurationNode, XMLSerializable
// stores relationships for the map of entities
private void encodeObjRelationshipsAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
for (ObjEntity entity : new TreeMap<>(getObjEntityMap()).values()) {
- entity.getDeclaredRelationships().stream().filter(r -> !r.isRuntime())
+ entity.getDeclaredRelationships().stream()
+ .filter(r -> !r.isRuntime())
+ .sorted(Comparator.comparing(Relationship::getName))
.forEach(r -> r.encodeAsXML(encoder, delegate));
}
}