Add support for PersistentBag #5781
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 10 May 2016 10:41:55 +0000 (12:41 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 10 May 2016 10:41:55 +0000 (12:41 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java

index ceca3e97e99c4e900c972ce3b06f1243fbe28574..8cffe58e306554283371eb681a154eb5b4bb2485 100644 (file)
@@ -48,7 +48,8 @@ public class ProxyUtils {
     public static enum CollectionType {
         SET,
         LIST,
-        MAP;
+        MAP,
+        BAG;
 
         @Override
         public String toString() {
@@ -56,9 +57,13 @@ public class ProxyUtils {
         }
     }
 
-    public static Object getCollectionType(Object obj) {
+    public static Object getCollectionType(Object obj, Class<?> clazz) {
         if(obj != null) {
             if(obj instanceof List) {
+               //the field in PersistentBag is called "bag" although it is an ArrayList -> #
+               if(clazz.equals(PersistentBag.class)){
+                       return CollectionType.BAG;
+               }
                 return CollectionType.LIST;
             }
             if(obj instanceof Set) {
index e37e53034929c7e339fea7df90b0034a01cf7f34..1b2fc8abc59ff18f58b1931ffa4fc629140f1b2f 100644 (file)
@@ -1347,7 +1347,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                                if (clazz != null) {
                                        //CollectionField cf = cachedCommonService.getCollectionField(col);
                                        //cachedCommonService.updatePersistentCollection(cf);
-                                   Object collectionType = ProxyUtils.getCollectionType(obj);
+                                   Object collectionType = ProxyUtils.getCollectionType(obj, clazz);
                                        Field field = clazz.getDeclaredField(collectionType.toString());
                                        field.setAccessible(true);
                                        field.set(this, obj);