fix #7212 preventing loaded entities from being replaces by uninitialized proxies
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 23 Jan 2018 13:14:14 +0000 (14:14 +0100)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Wed, 24 Jan 2018 12:30:16 +0000 (13:30 +0100)
cdmlib-cache/src/main/java/eu/etaxonomy/cdm/cache/CacheLoader.java
cdmlib-cache/src/main/java/eu/etaxonomy/cdm/cache/EntityCacherDebugResult.java
cdmlib-cache/src/main/java/eu/etaxonomy/cdm/cache/ProxyUtils.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());
 
index 2aa383c7fbf815d131f891bb59baa3279b3606a1..e6315f391907d417bfb5176d9defa12c1d5bfb00 100644 (file)
@@ -363,7 +363,7 @@ public class EntityCacherDebugResult {
             childCei.setField(field);
 
             if(o != null) {
-                boolean isProxy = ProxyUtils.isProxy(o);
+                boolean isProxy = ProxyUtils.isUninitializedProxy(o);
 
                 childCei.setProxy(isProxy);
                 if(!isProxy) {
index 1078397c69e4cfb685c5ee98dc83ec614a213421..4da60cf7b88b83507e873eee6e30730582b024d3 100644 (file)
@@ -153,7 +153,7 @@ public class ProxyUtils {
         return o;
     }
 
-    public static boolean isProxy(Object o) {
+    public static boolean isUninitializedProxy(Object o) {
         if(o != null && o instanceof HibernateProxy) {
             LazyInitializer hli = ((HibernateProxy)o).getHibernateLazyInitializer();
             if(hli.isUninitialized()) {