CdmTransientEntityCacher : overriding cache field only in the case of initialised...
[taxeditor.git] / eu.etaxonomy.taxeditor.cdmlib / src / main / java / eu / etaxonomy / taxeditor / remoting / cache / CdmTransientEntityCacher.java
index ffdc3fbc82ed04f32f45225de67c8493279a2a04..869d3deed150c1998a526a73c35fcb7264e96704 100644 (file)
@@ -386,10 +386,7 @@ public class CdmTransientEntityCacher  {
                     field.set(cdmEntity, o);
                 }
             }
-            // making sure that the field in cached cdm entity is always
-            // up-to-date by setting to the value of the cdm entity being loaded
-            // the only execption to this is found below
-            field.set(cachedCdmEntity, o);
+
             //field.set(cdmEntity, o);
             CdmBase cdmEntityInSubGraph = null;
             if(o != null
@@ -400,6 +397,10 @@ public class CdmTransientEntityCacher  {
                     logger.info("found initialised cdm entity '" + fieldName + "' in object of type " + clazz.getName() + " with id " + cdmEntity.getId());
                     cdmEntityInSubGraph  = (CdmBase)o;
                     CdmBase cachedCdmEntityInSubGraph = getFromCache(cdmEntityInSubGraph);
+                    // making sure that the field in cached cdm entity is always
+                    // up-to-date by setting to the value of the cdm entity being loaded
+                    // the only execption to this is found below
+                    field.set(cachedCdmEntity, o);
                     // the only exception to updating the field to the latest value
                     // is the case where the field has been already initialised, cached and
                     // is not the same as the one in the cache, in which case we set the value