Fix flattened attributes with optimistic locking

Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/20d20c71
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/20d20c71
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/20d20c71

Branch: refs/heads/master
Commit: 20d20c71ddbe6cbb81ec482c3f907f07ca017db2
Parents: 240c815
Author: John Huss <johnth...@apache.org>
Authored: Wed May 2 10:05:22 2018 -0500
Committer: John Huss <johnth...@gmail.com>
Committed: Wed May 2 10:16:04 2018 -0500

----------------------------------------------------------------------
 .../access/DataNodeSyncQualifierDescriptor.java       | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/20d20c71/cayenne-server/src/main/java/org/apache/cayenne/access/DataNodeSyncQualifierDescriptor.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/main/java/org/apache/cayenne/access/DataNodeSyncQualifierDescriptor.java
 
b/cayenne-server/src/main/java/org/apache/cayenne/access/DataNodeSyncQualifierDescriptor.java
index e5cd484..176227c 100644
--- 
a/cayenne-server/src/main/java/org/apache/cayenne/access/DataNodeSyncQualifierDescriptor.java
+++ 
b/cayenne-server/src/main/java/org/apache/cayenne/access/DataNodeSyncQualifierDescriptor.java
@@ -102,18 +102,18 @@ class DataNodeSyncQualifierDescriptor {
                                                attributes.add(dbAttribute);
                                                valueTransformers.add(input -> {
                             ObjectId id = (ObjectId) input.getNodeId();
-                            return 
id.getIdSnapshot().get(dbAttrPair.getSourceName());
+                            return 
id.getIdSnapshot().get(dbAttrPair.getTargetName());
                         });
-                                       }
-                               }
-                       }
-               }
+                    }
+                }
+            }
+        }
 
-               if (usingOptimisticLocking) {
+               if (descriptor.isMaster() && usingOptimisticLocking) {
 
                        for (final ObjAttribute attribute : 
descriptor.getEntity().getAttributes()) {
 
-                               if (attribute.isUsedForLocking()) {
+                               if (attribute.isUsedForLocking() && 
!attribute.isFlattened()) {
                                        // only care about first step in a 
flattened attribute
                                        DbAttribute dbAttribute = (DbAttribute) 
attribute.getDbPathIterator().next();
 

Reply via email to