cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnth...@apache.org
Subject cayenne git commit: Fix unnecessary fetching of relationships when optimistic locking is enabled for an entity, but not for all its to-one relationships
Date Mon, 13 Jun 2016 16:28:23 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 85852f92e -> 81f99c3b5


Fix unnecessary fetching of relationships when optimistic locking is enabled for an entity,
but not for all its to-one relationships


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

Branch: refs/heads/master
Commit: 81f99c3b552328f54eaec49cf0bd1d5e6536363f
Parents: 85852f9
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:26:40 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/81f99c3b/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 45b7176..73b4f78 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<>();
@@ -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