add additional debugging in AbstractPersistentCollection
authorKatja Luther <k.luther@bgbm.org>
Wed, 17 Feb 2021 13:07:18 +0000 (14:07 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 17 Feb 2021 13:08:08 +0000 (14:08 +0100)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java

index f12985df2d6ecbc5ed164f0a355e01de5b545bfa..267e8ca3a9caecd8d9eb5575dd9daa5320f44bf6 100644 (file)
@@ -63,7 +63,7 @@ import eu.etaxonomy.taxeditor.service.ICachedCommonService;
  * NOTE: For updating this class to the latest hibernate version, update the serialVersionUID as
  *       described above, copy the new class to the old class BUT keep those 5 places marked with
  *       ##REMOTING-KEEP##
- * 
+ *
  * @author Gavin King
  * @author Cherian Mathew
  */
@@ -274,7 +274,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
 
 
                        isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
-                       
+
                        if ( !isJTA ) {
                                // Explicitly handle the transactions only if we're not in
                                // a JTA environment.  A lazy loading temporary session can
@@ -638,7 +638,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
            // both when using property paths and switching off conversations
            if(session == null && remoting) {
                remoteInitialize();
-           } else { 
+           } else {
            //keep formatting below to ease update to newer hibernate version
                //##REMOTING-KEEP END##
            withTemporarySessionIfNeeded(
@@ -1236,7 +1236,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        this.orphan = orphan;
                }
 
-               public void replace(CollectionPersister persister, Map copyCache) {
+               @Override
+        public void replace(CollectionPersister persister, Map copyCache) {
                        if ( addedValue != null ) {
                                addedValue = getReplacement( persister.getElementType(), addedValue, copyCache );
                        }
@@ -1374,21 +1375,21 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                this.owner = owner;
        }
 
-       
-/** ##REMOTING-KEEP## ####################################################### 
-    
+
+/** ##REMOTING-KEEP## #######################################################
+
     ADDED PART: Below is the section of code which makes remote service calls.
     Keeps this code when upgrading to newer hibernate version. Also keep
     other code marked with ##REMOTING-KEEP## in the following 5 methods:
-    
+
     {@link #initialize(boolean)}
        {@link #readSize()}
        {@link #readIndexExistence(Object)}
        {@link #readElementExistence(Object)}
        {@link #readElementByIndex(Object)}
-    
+
     ######################################################################### */
-    
+
        private static CdmApplicationRemoteConfiguration configuration;
        private static boolean remoting = false;
 
@@ -1400,7 +1401,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        private void remoteInitialize() {
 
                if (getOwner() != null && !initialized) {
-
+                   Object collectionType = null;
+                   Field field = null;
                        try {
                                String role = getRole();
                                String fieldName = role.substring(role.lastIndexOf(".") + 1);
@@ -1431,15 +1433,18 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                                if (clazz != null) {
                                        //CollectionField cf = cachedCommonService.getCollectionField(col);
                                        //cachedCommonService.updatePersistentCollection(cf);
-                                   Object collectionType = ProxyUtils.getCollectionType(obj, clazz);
-                                       Field field = clazz.getDeclaredField(collectionType.toString());
+                                   collectionType = ProxyUtils.getCollectionType(obj, clazz);
+                                   field = clazz.getDeclaredField(collectionType.toString());
                                        field.setAccessible(true);
                                        field.set(this, obj);
                                        ProxyUtils.setRoleValueInOwner(owner, role, obj);
 
                                }
                        } catch (Exception ex) {
-                               throw new CdmEagerLoadingException(ex);
+                           String originalMessage = ex.getMessage();
+
+                           String message = originalMessage + " - field: " + field + " - collectionType: " + collectionType.toString();
+                           throw new CdmEagerLoadingException(message);
                        }
                }
        }