cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnth...@apache.org
Subject [6/6] cayenne git commit: Fix unnecessary fetching of relationships when optimistic locking is enabled for an entity, but not for all its relationships
Date Tue, 09 Aug 2016 16:30:35 GMT
Fix unnecessary fetching of relationships when optimistic locking is enabled for an entity,
but not for all its relationships


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

Branch: refs/heads/ics11
Commit: 6b73bad7888f213ad609dab78b81236e61c8adec
Parents: 4d9a66c
Author: John Huss <johnthuss@apache.org>
Authored: Mon Jun 13 11:00:33 2016 -0500
Committer: John Huss <johnthuss@apache.org>
Committed: Mon Jun 13 11:00:33 2016 -0500

----------------------------------------------------------------------
 .../src/main/java/org/apache/cayenne/access/ObjectDiff.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/6b73bad7/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectDiff.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectDiff.java b/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectDiff.java
index f85d482..f54c905 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectDiff.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectDiff.java
@@ -88,7 +88,7 @@ class ObjectDiff extends NodeDiff {
         if (state == PersistenceState.COMMITTED || state == PersistenceState.DELETED
                 || state == PersistenceState.MODIFIED) {
 
-            ObjEntity entity = entityResolver.getObjEntity(entityName);
+            final ObjEntity entity = entityResolver.getObjEntity(entityName);
             final boolean lock = entity.getLockType() == ObjEntity.LOCK_TYPE_OPTIMISTIC;
 
             this.snapshot = new HashMap<String, Object>();
@@ -109,9 +109,10 @@ class ObjectDiff extends NodeDiff {
 
                 @Override
                 public boolean visitToOne(ToOneProperty property) {
-
+                    boolean isUsedForLocking = entity.getRelationship(property.getName()).isUsedForLocking();
+                    
                     // eagerly resolve optimistically locked relationships
-                    Object target = lock ? property.readProperty(object) : property.readPropertyDirectly(object);
+                    Object target = isUsedForLocking ? property.readProperty(object) : property.readPropertyDirectly(object);
 
                     if (target instanceof Persistent) {
                         target = ((Persistent) target).getObjectId();


Mime
View raw message