moved cached cdm entity field update for only CdmBase objects
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 18 Mar 2015 17:35:43 +0000 (17:35 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 18 Mar 2015 17:35:43 +0000 (17:35 +0000)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CacheLoader.java

index a1e430cb623e1b66f4626767f352adbbc6ad6676..02ae45670a72f0d9e797d28937ec425bbc896d2d 100644 (file)
@@ -315,20 +315,22 @@ public class CacheLoader {
             }
             field.setAccessible(true);
             Object o = field.get(cdmEntity);
+            // resetting the value in cdm entity to the deproxied object
             o = ProxyUtils.deproxy(o);
             field.set(cdmEntity, o);
 
             CdmBase cdmEntityInSubGraph = null;
-            if(update) {
-                    // if we are in update mode we have to make the field of the cached entity
-                    // up-to-date by setting it to the value of the cdm entity being loaded
-                    // NOTE : two exceptions to this are found below
-                    field.set(cachedCdmEntity, o);
 
-            }
             if(o != null && !ProxyUtils.isProxy(o)) {
                 if(CdmBase.class.isAssignableFrom(o.getClass())) {
                     logger.info("found initialised cdm entity '" + fieldName + "' in object of type " + clazz.getName() + " with id " + cdmEntity.getId());
+                    if(update) {
+                        // if we are in update mode we have to make the field of the cached entity
+                        // up-to-date by setting it to the value of the cdm entity being loaded
+                        // NOTE : two exceptions to this are found below
+                        field.set(cachedCdmEntity, o);
+
+                    }
                     cdmEntityInSubGraph  = (CdmBase)o;
                     CdmBase cachedCdmEntityInSubGraph = cdmCacher.getFromCache(cdmEntityInSubGraph);