fix #7212 preventing loaded entities from being replaces by uninitialized proxies
[cdmlib.git] / cdmlib-cache / src / main / java / eu / etaxonomy / cdm / cache / CacheLoader.java
index 7f352a7986ecdebdc71ab33d28e2c30ce0b84bd8..99e8d586a868b919f5c060c23a0a4e0eccfa4eef 100644 (file)
@@ -381,7 +381,7 @@ public class CacheLoader {
             Object cachedo = field.get(cachedCdmEntity);
             CdmBase cdmEntityInSubGraph = null;
 
-            if(update || ProxyUtils.isProxy(cachedo)) {
+            if(!ProxyUtils.isUninitializedProxy(o) && (update || ProxyUtils.isUninitializedProxy(cachedo))) {
                 // 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
                 //
@@ -394,7 +394,7 @@ public class CacheLoader {
 
             }
 
-            if(o != null && !ProxyUtils.isProxy(o)) {
+            if(o != null && !ProxyUtils.isUninitializedProxy(o)) {
                 if(CdmBase.class.isAssignableFrom(o.getClass())) {
                     logger.info("found initialised cdm entity '" + fieldName + "' in object of type " + clazz.getName() + " with id " + cdmEntity.getId());