Fix remoting code compilation errors
authorCherian Mathew <c.mathew@bgbm.org>
Thu, 25 Jun 2015 15:21:07 +0000 (17:21 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Thu, 25 Jun 2015 15:21:07 +0000 (17:21 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/lazyloading/CdmLazyLoader.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java

index e98d40df7db0f293682d58f91da538d3f74caa1a..db64c568cc1ca7b2e7289ccecfbad00cd8b5c91e 100644 (file)
@@ -1,6 +1,5 @@
 package eu.etaxonomy.cdm.api.lazyloading;
 
 package eu.etaxonomy.cdm.api.lazyloading;
 
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -37,24 +36,24 @@ import eu.etaxonomy.cdm.model.common.PersistentMultiLanguageText;
 public class CdmLazyLoader {
 
 
 public class CdmLazyLoader {
 
 
-       private Set classes = new HashSet();
-       
+       private final Set classes = new HashSet();
+
        public static boolean enableWeaving = true;
        private static Set<String> classesToIgnore = new HashSet<String>();
        public static boolean enableWeaving = true;
        private static Set<String> classesToIgnore = new HashSet<String>();
-       
-       
+
+
        @Autowired
        private ICommonService commonService;
 
        public CdmLazyLoader() {
                //classesToIgnore.add("eu.etaxonomy.cdm.model.common.TermVocabulary");
                //classesToIgnore.add("eu.etaxonomy.cdm.model.common.OrderedTermVocabulary");
        @Autowired
        private ICommonService commonService;
 
        public CdmLazyLoader() {
                //classesToIgnore.add("eu.etaxonomy.cdm.model.common.TermVocabulary");
                //classesToIgnore.add("eu.etaxonomy.cdm.model.common.OrderedTermVocabulary");
-               
+
        }
        }
-       
+
        /**
         *  Point cut for the 'initialize' method of the AbstractLazyInitializer.
        /**
         *  Point cut for the 'initialize' method of the AbstractLazyInitializer.
-        *  
+        *
         */
        @Pointcut("execution(* org.hibernate.proxy.AbstractLazyInitializer.initialize())")
        public void possibleEntityLazyInitializationException() {
         */
        @Pointcut("execution(* org.hibernate.proxy.AbstractLazyInitializer.initialize())")
        public void possibleEntityLazyInitializationException() {
@@ -63,43 +62,43 @@ public class CdmLazyLoader {
 
        /**
         *  'Around' advice for the initialization of CDM Entity Objects
 
        /**
         *  'Around' advice for the initialization of CDM Entity Objects
-        *  
+        *
         */
        @Around(value = "possibleEntityLazyInitializationException()")
         */
        @Around(value = "possibleEntityLazyInitializationException()")
-       public Object preloadEntityOnDemand(ProceedingJoinPoint pjp) throws Throwable {          
+       public Object preloadEntityOnDemand(ProceedingJoinPoint pjp) throws Throwable {
                if(enableWeaving) {
                if(enableWeaving) {
-                       LazyInitializer ll = (LazyInitializer)pjp.getTarget();          
-                       if(ll.isUninitialized()) {                              
+                       LazyInitializer ll = (LazyInitializer)pjp.getTarget();
+                       if(ll.isUninitialized()) {
                                int classid = ((Integer)ll.getIdentifier()).intValue();
                                System.out.print("--> AspectJ Compile-Time Weaving " + ll.getEntityName() + " with id " + classid);
                                int classid = ((Integer)ll.getIdentifier()).intValue();
                                System.out.print("--> AspectJ Compile-Time Weaving " + ll.getEntityName() + " with id " + classid);
-                               Class clazz = (Class<? extends CdmBase>) Class.forName(ll.getEntityName());
+                               Class clazz = Class.forName(ll.getEntityName());
                                CdmBase cdmBase = CdmBase.deproxy(commonService.find(clazz,classid),clazz);
                                ll.setImplementation(cdmBase);
                                System.out.println("....Done");
                        }
                }
                                CdmBase cdmBase = CdmBase.deproxy(commonService.find(clazz,classid),clazz);
                                ll.setImplementation(cdmBase);
                                System.out.println("....Done");
                        }
                }
-               return pjp.proceed();                             
+               return pjp.proceed();
        }
        }
-       
+
 
        /**
         *  Point cut for the 'initialize' method of the AbstractPersistentCollection.
 
        /**
         *  Point cut for the 'initialize' method of the AbstractPersistentCollection.
-        *  
+        *
         */
        @Pointcut("execution(protected final void org.hibernate.collection.internal.AbstractPersistentCollection.initialize(..))")
        public void possibleCollectionLazyInitializationException() {
        }
         */
        @Pointcut("execution(protected final void org.hibernate.collection.internal.AbstractPersistentCollection.initialize(..))")
        public void possibleCollectionLazyInitializationException() {
        }
-       
+
        /**
         *  'Around' advice for the initialization of Collection objects
        /**
         *  'Around' advice for the initialization of Collection objects
-        *  
+        *
         */
         */
-       @Around(value = "possibleCollectionLazyInitializationException()")      
-       public Object preloadCollectionOnDemand(ProceedingJoinPoint pjp) throws Throwable {              
+       @Around(value = "possibleCollectionLazyInitializationException()")
+       public Object preloadCollectionOnDemand(ProceedingJoinPoint pjp) throws Throwable {
                if(enableWeaving) {
                        PersistentCollection ps = (PersistentCollection) pjp.getTarget();
                        if (ps.getOwner() != null && !classesToIgnore.contains(ps.getOwner().getClass().getName()) && !ps.wasInitialized() &&  !classes.contains(ps.getKey())) {
                if(enableWeaving) {
                        PersistentCollection ps = (PersistentCollection) pjp.getTarget();
                        if (ps.getOwner() != null && !classesToIgnore.contains(ps.getOwner().getClass().getName()) && !ps.wasInitialized() &&  !classes.contains(ps.getKey())) {
-                               System.out.print("--> AspectJCompile-Time Weaving " + ps.getRole());                
+                               System.out.print("--> AspectJCompile-Time Weaving " + ps.getRole());
                                classes.add(ps.getKey());
                                try {
                                        String role = ps.getRole();
                                classes.add(ps.getKey());
                                try {
                                        String role = ps.getRole();
@@ -107,29 +106,31 @@ public class CdmLazyLoader {
                                        System.out.print(", field : " + fieldName);
                                        Object owner = ps.getOwner();
 
                                        System.out.print(", field : " + fieldName);
                                        Object owner = ps.getOwner();
 
-                                       PersistentCollection col = commonService.initializeCollection(ps); 
+                                       Object col = commonService.initializeCollection(((CdmBase)owner).getUuid(), fieldName);
                                        ps.afterInitialize();
 
                                        ps.afterInitialize();
 
-                                       Class<?> clazz = ps.getClass();
-                                       if (clazz != null) {    
-                                               CollectionField cf = getCollectionField(col);
-                                               Field field = clazz.getDeclaredField(cf.getFieldName());
-                                               field.setAccessible(true);
-                                               field.set(ps, cf.getCollection());                             
-                                       }               
+//                                     Class<?> clazz = ps.getClass();
+//                                     if (clazz != null) {
+//                                             CollectionField cf = getCollectionField(col);
+//                                             Field field = clazz.getDeclaredField(cf.getFieldName());
+//                                             field.setAccessible(true);
+//                                             field.set(ps, cf.getCollection());
+//                                     }
+
                                } catch (Exception ex) {
                                        ex.printStackTrace();
                                        System.out.println("Error in ReattachSessionAspect : " + ex.getMessage());
                                } finally {
                                        classes.remove(ps.getKey());
                                        System.out.println("....Done");
                                } catch (Exception ex) {
                                        ex.printStackTrace();
                                        System.out.println("Error in ReattachSessionAspect : " + ex.getMessage());
                                } finally {
                                        classes.remove(ps.getKey());
                                        System.out.println("....Done");
-                               }       
+                                       throw new Exception("This code is invalid");
+                               }
                        }
                        }
-               } 
+               }
                return pjp.proceed();
 
        }
                return pjp.proceed();
 
        }
-       
+
        private CollectionField getCollectionField(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet) {
        private CollectionField getCollectionField(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet) {
@@ -150,12 +151,12 @@ public class CdmLazyLoader {
                }
                return null;
        }
                }
                return null;
        }
-       
+
        private String getCollectionFieldName(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet || pc instanceof PersistentSortedSet) {
                                return "set";
        private String getCollectionFieldName(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet || pc instanceof PersistentSortedSet) {
                                return "set";
-                       }                       
+                       }
                        if(pc instanceof PersistentList) {
                                return "list";
                        }
                        if(pc instanceof PersistentList) {
                                return "list";
                        }
@@ -165,19 +166,19 @@ public class CdmLazyLoader {
                }
                return null;
        }
                }
                return null;
        }
-       
+
        private class CollectionField {
        private class CollectionField {
-               private Object col;
-               private String fieldName;
+               private final Object col;
+               private final String fieldName;
                public CollectionField(Object col, String fieldName) {
                        this.col = col;
                        this.fieldName = fieldName;
                }
                public CollectionField(Object col, String fieldName) {
                        this.col = col;
                        this.fieldName = fieldName;
                }
-               
+
                public Object getCollection() {
                        return this.col;
                }
                public Object getCollection() {
                        return this.col;
                }
-               
+
                public String getFieldName() {
                        return this.fieldName;
                }
                public String getFieldName() {
                        return this.fieldName;
                }
index e6841035b006c86e34fadc4ffca125640c6a7789..1bc42c44fbef5dc66862dd34bcc8e7793e529717 100644 (file)
@@ -26,7 +26,6 @@
 package org.hibernate.collection.internal;
 
 import java.io.Serializable;
 package org.hibernate.collection.internal;
 
 import java.io.Serializable;
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -78,7 +77,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        private static final Logger log = Logger.getLogger( AbstractPersistentCollection.class );
 
        private static final long serialVersionUID = -7238232378593030571L;
        private static final Logger log = Logger.getLogger( AbstractPersistentCollection.class );
 
        private static final long serialVersionUID = -7238232378593030571L;
-       
+
        private transient SessionImplementor session;
        private boolean initialized;
        private transient List<DelayedOperation> operationQueue;
        private transient SessionImplementor session;
        private boolean initialized;
        private transient List<DelayedOperation> operationQueue;
@@ -97,31 +96,38 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        private String sessionFactoryUuid;
        private boolean specjLazyLoad = false;
 
        private String sessionFactoryUuid;
        private boolean specjLazyLoad = false;
 
-       public final String getRole() {
+       @Override
+    public final String getRole() {
                return role;
        }
 
                return role;
        }
 
-       public final Serializable getKey() {
+       @Override
+    public final Serializable getKey() {
                return key;
        }
 
                return key;
        }
 
-       public final boolean isUnreferenced() {
+       @Override
+    public final boolean isUnreferenced() {
                return role == null;
        }
 
                return role == null;
        }
 
-       public final boolean isDirty() {
+       @Override
+    public final boolean isDirty() {
                return dirty;
        }
 
                return dirty;
        }
 
-       public final void clearDirty() {
+       @Override
+    public final void clearDirty() {
                dirty = false;
        }
 
                dirty = false;
        }
 
-       public final void dirty() {
+       @Override
+    public final void dirty() {
                dirty = true;
        }
 
                dirty = true;
        }
 
-       public final Serializable getStoredSnapshot() {
+       @Override
+    public final Serializable getStoredSnapshot() {
                return storedSnapshot;
        }
 
                return storedSnapshot;
        }
 
@@ -130,7 +136,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * Is the initialized collection empty?
         */
        /**
         * Is the initialized collection empty?
         */
-       public abstract boolean empty();
+       @Override
+    public abstract boolean empty();
 
        /**
         * Called by any read-only method of the collection interface
 
        /**
         * Called by any read-only method of the collection interface
@@ -151,9 +158,9 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        else {
                                // In remoting we are sure that session is null
                                // both when using property paths and switching off conversations
                        else {
                                // In remoting we are sure that session is null
                                // both when using property paths and switching off conversations
-                               if(session == null && remoting) {                               
+                               if(session == null && remoting) {
                                        log.info("--> readSize, of " + getRole() + " with key " + getKey());
                                        log.info("--> readSize, of " + getRole() + " with key " + getKey());
-                                       read();                                                         
+                                       read();
                                } else {
                                        boolean isExtraLazy = withTemporarySessionIfNeeded(
                                                        new LazyInitializationWork<Boolean>() {
                                } else {
                                        boolean isExtraLazy = withTemporarySessionIfNeeded(
                                                        new LazyInitializationWork<Boolean>() {
@@ -236,7 +243,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                                        .getTransactionContext().getTransactionEnvironment()
                                        .getTransactionFactory()
                                        .compatibleWithJtaSynchronization();
                                        .getTransactionContext().getTransactionEnvironment()
                                        .getTransactionFactory()
                                        .compatibleWithJtaSynchronization();
-                       
+
                        if ( !isJTA ) {
                                // Explicitly handle the transactions only if we're not in
                                // a JTA environment.  A lazy loading temporary session can
                        if ( !isJTA ) {
                                // Explicitly handle the transactions only if we're not in
                                // a JTA environment.  A lazy loading temporary session can
@@ -245,7 +252,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                                // multiple transactions.
                                ( ( Session) session ).beginTransaction();
                        }
                                // multiple transactions.
                                ( ( Session) session ).beginTransaction();
                        }
-                       
+
                        session.getPersistenceContext().addUninitializedDetachedCollection(
                                        session.getFactory().getCollectionPersister( getRole() ),
                                        this
                        session.getPersistenceContext().addUninitializedDetachedCollection(
                                        session.getFactory().getCollectionPersister( getRole() ),
                                        this
@@ -286,9 +293,9 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                if ( !initialized ) {
                        // In remoting we are sure that session is null
                        // both when using property paths and switching off conversations
                if ( !initialized ) {
                        // In remoting we are sure that session is null
                        // both when using property paths and switching off conversations
-                       if(session == null && remoting) {                       
+                       if(session == null && remoting) {
                                log.info("--> readIndexExistence, of " + getRole() + " with key " + getKey());
                                log.info("--> readIndexExistence, of " + getRole() + " with key " + getKey());
-                               read();                                                                         
+                               read();
                        } else {
                                Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded(
                                                new LazyInitializationWork<Boolean>() {
                        } else {
                                Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded(
                                                new LazyInitializationWork<Boolean>() {
@@ -323,8 +330,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        // both when using property paths and switching off conversations
                        if(session == null && remoting) {
                                log.info("--> readElementExistence, of " + getRole() + " with key " + getKey());
                        // both when using property paths and switching off conversations
                        if(session == null && remoting) {
                                log.info("--> readElementExistence, of " + getRole() + " with key " + getKey());
-                               read();                         
-                               
+                               read();
+
                        } else {
                                Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded(
                                                new LazyInitializationWork<Boolean>() {
                        } else {
                                Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded(
                                                new LazyInitializationWork<Boolean>() {
@@ -359,10 +366,10 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                if ( !initialized ) {
                        // In remoting we are sure that session is null
                        // both when using property paths and switching off conversations
                if ( !initialized ) {
                        // In remoting we are sure that session is null
                        // both when using property paths and switching off conversations
-                       if(session == null && remoting) {                               
+                       if(session == null && remoting) {
                                log.info("--> readElementByIndex, of " + getRole() + " with key " + getKey());
                                log.info("--> readElementByIndex, of " + getRole() + " with key " + getKey());
-                               read();                         
-                               
+                               read();
+
                        } else {
                                class ExtraLazyElementByIndexReader implements LazyInitializationWork {
                                        private boolean isExtraLazy;
                        } else {
                                class ExtraLazyElementByIndexReader implements LazyInitializationWork {
                                        private boolean isExtraLazy;
@@ -510,7 +517,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * After flushing, re-init snapshot state.
         */
        /**
         * After flushing, re-init snapshot state.
         */
-       public void setSnapshot(Serializable key, String role, Serializable snapshot) {
+       @Override
+    public void setSnapshot(Serializable key, String role, Serializable snapshot) {
                this.key = key;
                this.role = role;
                this.storedSnapshot = snapshot;
                this.key = key;
                this.role = role;
                this.storedSnapshot = snapshot;
@@ -520,7 +528,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         * After flushing, clear any "queued" additions, since the
         * database state is now synchronized with the memory state.
         */
         * After flushing, clear any "queued" additions, since the
         * database state is now synchronized with the memory state.
         */
-       public void postAction() {
+       @Override
+    public void postAction() {
                operationQueue = null;
                cachedSize = -1;
                clearDirty();
                operationQueue = null;
                cachedSize = -1;
                clearDirty();
@@ -540,14 +549,16 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * return the user-visible collection (or array) instance
         */
        /**
         * return the user-visible collection (or array) instance
         */
-       public Object getValue() {
+       @Override
+    public Object getValue() {
                return this;
        }
 
        /**
         * Called just before reading any rows from the JDBC result set
         */
                return this;
        }
 
        /**
         * Called just before reading any rows from the JDBC result set
         */
-       public void beginRead() {
+       @Override
+    public void beginRead() {
                // override on some subclasses
                initializing = true;
        }
                // override on some subclasses
                initializing = true;
        }
@@ -555,12 +566,14 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * Called after reading all rows from the JDBC result set
         */
        /**
         * Called after reading all rows from the JDBC result set
         */
-       public boolean endRead() {
+       @Override
+    public boolean endRead() {
                //override on some subclasses
                return afterInitialize();
        }
 
                //override on some subclasses
                return afterInitialize();
        }
 
-       public boolean afterInitialize() {
+       @Override
+    public boolean afterInitialize() {
                setInitialized();
                //do this bit after setting initialized to true or it will recurse
                if ( operationQueue != null ) {
                setInitialized();
                //do this bit after setting initialized to true or it will recurse
                if ( operationQueue != null ) {
@@ -586,14 +599,14 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                // In remoting we are sure that session is null
                // both when using property paths and switching off conversations
                if(session == null && remoting) {
                // In remoting we are sure that session is null
                // both when using property paths and switching off conversations
                if(session == null && remoting) {
-                       remoteInitialize();                     
+                       remoteInitialize();
                }
                }
-               
+
                if ( initialized ) {
                        return;
                }
 
                if ( initialized ) {
                        return;
                }
 
-               
+
                withTemporarySessionIfNeeded(
                                new LazyInitializationWork<Object>() {
                                        @Override
                withTemporarySessionIfNeeded(
                                new LazyInitializationWork<Object>() {
                                        @Override
@@ -635,7 +648,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         * Could the application possibly have a direct reference to
         * the underlying collection implementation?
         */
         * Could the application possibly have a direct reference to
         * the underlying collection implementation?
         */
-       public boolean isDirectlyAccessible() {
+       @Override
+    public boolean isDirectlyAccessible() {
                return directlyAccessible;
        }
 
                return directlyAccessible;
        }
 
@@ -644,7 +658,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         *
         * @return true if this was currently associated with the given session
         */
         *
         * @return true if this was currently associated with the given session
         */
-       public final boolean unsetSession(SessionImplementor currentSession) {
+       @Override
+    public final boolean unsetSession(SessionImplementor currentSession) {
                prepareForPossibleSpecialSpecjInitialization();
                if ( currentSession == this.session ) {
                        this.session = null;
                prepareForPossibleSpecialSpecjInitialization();
                if ( currentSession == this.session ) {
                        this.session = null;
@@ -679,7 +694,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         * @throws HibernateException if the collection was already associated
         * with another open session
         */
         * @throws HibernateException if the collection was already associated
         * with another open session
         */
-       public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
+       @Override
+    public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
                if ( session == this.session ) {
                        return false;
                }
                if ( session == this.session ) {
                        return false;
                }
@@ -711,7 +727,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * Do we need to completely recreate this collection when it changes?
         */
        /**
         * Do we need to completely recreate this collection when it changes?
         */
-       public boolean needsRecreate(CollectionPersister persister) {
+       @Override
+    public boolean needsRecreate(CollectionPersister persister) {
                return false;
        }
 
                return false;
        }
 
@@ -719,7 +736,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         * To be called internally by the session, forcing
         * immediate initialization.
         */
         * To be called internally by the session, forcing
         * immediate initialization.
         */
-       public final void forceInitialization() throws HibernateException {
+       @Override
+    public final void forceInitialization() throws HibernateException {
                if ( !initialized ) {
                        if ( initializing ) {
                                throw new AssertionFailure( "force initialize loading collection" );
                if ( !initialized ) {
                        if ( initializing ) {
                                throw new AssertionFailure( "force initialize loading collection" );
@@ -746,38 +764,45 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * Is this instance initialized?
         */
        /**
         * Is this instance initialized?
         */
-       public final boolean wasInitialized() {
+       @Override
+    public final boolean wasInitialized() {
                return initialized;
        }
 
                return initialized;
        }
 
-       public boolean isRowUpdatePossible() {
+       @Override
+    public boolean isRowUpdatePossible() {
                return true;
        }
 
        /**
         * Does this instance have any "queued" additions?
         */
                return true;
        }
 
        /**
         * Does this instance have any "queued" additions?
         */
-       public final boolean hasQueuedOperations() {
+       @Override
+    public final boolean hasQueuedOperations() {
                return operationQueue != null;
        }
 
        /**
         * Iterate the "queued" additions
         */
                return operationQueue != null;
        }
 
        /**
         * Iterate the "queued" additions
         */
-       public final Iterator queuedAdditionIterator() {
+       @Override
+    public final Iterator queuedAdditionIterator() {
                if ( hasQueuedOperations() ) {
                        return new Iterator() {
                                int i = 0;
 
                if ( hasQueuedOperations() ) {
                        return new Iterator() {
                                int i = 0;
 
-                               public Object next() {
+                               @Override
+                public Object next() {
                                        return operationQueue.get( i++ ).getAddedInstance();
                                }
 
                                        return operationQueue.get( i++ ).getAddedInstance();
                                }
 
-                               public boolean hasNext() {
+                               @Override
+                public boolean hasNext() {
                                        return i < operationQueue.size();
                                }
 
                                        return i < operationQueue.size();
                                }
 
-                               public void remove() {
+                               @Override
+                public void remove() {
                                        throw new UnsupportedOperationException();
                                }
                        };
                                        throw new UnsupportedOperationException();
                                }
                        };
@@ -790,7 +815,8 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
        /**
         * Iterate the "queued" additions
         */
        /**
         * Iterate the "queued" additions
         */
-       @SuppressWarnings({"unchecked"})
+       @Override
+    @SuppressWarnings({"unchecked"})
        public final Collection getQueuedOrphans(String entityName) {
                if ( hasQueuedOperations() ) {
                        Collection additions = new ArrayList( operationQueue.size() );
        public final Collection getQueuedOrphans(String entityName) {
                if ( hasQueuedOperations() ) {
                        Collection additions = new ArrayList( operationQueue.size() );
@@ -810,19 +836,22 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
         * Called before inserting rows, to ensure that any surrogate keys
         * are fully generated
         */
         * Called before inserting rows, to ensure that any surrogate keys
         * are fully generated
         */
-       public void preInsert(CollectionPersister persister) throws HibernateException {
+       @Override
+    public void preInsert(CollectionPersister persister) throws HibernateException {
        }
 
        /**
         * Called after inserting a row, to fetch the natively generated id
         */
        }
 
        /**
         * Called after inserting a row, to fetch the natively generated id
         */
-       public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException {
+       @Override
+    public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException {
        }
 
        /**
         * get all "orphaned" elements
         */
        }
 
        /**
         * get all "orphaned" elements
         */
-       public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException;
+       @Override
+    public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException;
 
        /**
         * Get the current session
 
        /**
         * Get the current session
@@ -839,15 +868,18 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        this.itr = itr;
                }
 
                        this.itr = itr;
                }
 
-               public boolean hasNext() {
+               @Override
+        public boolean hasNext() {
                        return itr.hasNext();
                }
 
                        return itr.hasNext();
                }
 
-               public Object next() {
+               @Override
+        public Object next() {
                        return itr.next();
                }
 
                        return itr.next();
                }
 
-               public void remove() {
+               @Override
+        public void remove() {
                        write();
                        itr.remove();
                }
                        write();
                        itr.remove();
                }
@@ -861,42 +893,51 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        this.itr = itr;
                }
 
                        this.itr = itr;
                }
 
-               @SuppressWarnings({"unchecked"})
+               @Override
+        @SuppressWarnings({"unchecked"})
                public void add(Object o) {
                        write();
                        itr.add( o );
                }
 
                public void add(Object o) {
                        write();
                        itr.add( o );
                }
 
-               public boolean hasNext() {
+               @Override
+        public boolean hasNext() {
                        return itr.hasNext();
                }
 
                        return itr.hasNext();
                }
 
-               public boolean hasPrevious() {
+               @Override
+        public boolean hasPrevious() {
                        return itr.hasPrevious();
                }
 
                        return itr.hasPrevious();
                }
 
-               public Object next() {
+               @Override
+        public Object next() {
                        return itr.next();
                }
 
                        return itr.next();
                }
 
-               public int nextIndex() {
+               @Override
+        public int nextIndex() {
                        return itr.nextIndex();
                }
 
                        return itr.nextIndex();
                }
 
-               public Object previous() {
+               @Override
+        public Object previous() {
                        return itr.previous();
                }
 
                        return itr.previous();
                }
 
-               public int previousIndex() {
+               @Override
+        public int previousIndex() {
                        return itr.previousIndex();
                }
 
                        return itr.previousIndex();
                }
 
-               public void remove() {
+               @Override
+        public void remove() {
                        write();
                        itr.remove();
                }
 
                        write();
                        itr.remove();
                }
 
-               @SuppressWarnings({"unchecked"})
+               @Override
+        @SuppressWarnings({"unchecked"})
                public void set(Object o) {
                        write();
                        itr.set( o );
                public void set(Object o) {
                        write();
                        itr.set( o );
@@ -911,63 +952,76 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                        this.set = set;
                }
 
                        this.set = set;
                }
 
-               @SuppressWarnings({"unchecked"})
+               @Override
+        @SuppressWarnings({"unchecked"})
                public boolean add(Object o) {
                        write();
                        return set.add( o );
                }
 
                public boolean add(Object o) {
                        write();
                        return set.add( o );
                }
 
-               @SuppressWarnings({"unchecked"})
+               @Override
+        @SuppressWarnings({"unchecked"})
                public boolean addAll(Collection c) {
                        write();
                        return set.addAll( c );
                }
 
                public boolean addAll(Collection c) {
                        write();
                        return set.addAll( c );
                }
 
-               public void clear() {
+               @Override
+        public void clear() {
                        write();
                        set.clear();
                }
 
                        write();
                        set.clear();
                }
 
-               public boolean contains(Object o) {
+               @Override
+        public boolean contains(Object o) {
                        return set.contains( o );
                }
 
                        return set.contains( o );
                }
 
-               public boolean containsAll(Collection c) {
+               @Override
+        public boolean containsAll(Collection c) {
                        return set.containsAll( c );
                }
 
                        return set.containsAll( c );
                }
 
-               public boolean isEmpty() {
+               @Override
+        public boolean isEmpty() {
                        return set.isEmpty();
                }
 
                        return set.isEmpty();
                }
 
-               public Iterator iterator() {
+               @Override
+        public Iterator iterator() {
                        return new IteratorProxy( set.iterator() );
                }
 
                        return new IteratorProxy( set.iterator() );
                }
 
-               public boolean remove(Object o) {
+               @Override
+        public boolean remove(Object o) {
                        write();
                        return set.remove( o );
                }
 
                        write();
                        return set.remove( o );
                }
 
-               public boolean removeAll(Collection c) {
+               @Override
+        public boolean removeAll(Collection c) {
                        write();
                        return set.removeAll( c );
                }
 
                        write();
                        return set.removeAll( c );
                }
 
-               public boolean retainAll(Collection c) {
+               @Override
+        public boolean retainAll(Collection c) {
                        write();
                        return set.retainAll( c );
                }
 
                        write();
                        return set.retainAll( c );
                }
 
-               public int size() {
+               @Override
+        public int size() {
                        return set.size();
                }
 
                        return set.size();
                }
 
-               public Object[] toArray() {
+               @Override
+        public Object[] toArray() {
                        return set.toArray();
                }
 
                        return set.toArray();
                }
 
-               @SuppressWarnings({"unchecked"})
+               @Override
+        @SuppressWarnings({"unchecked"})
                public Object[] toArray(Object[] array) {
                        return set.toArray( array );
                }
                public Object[] toArray(Object[] array) {
                        return set.toArray( array );
                }
@@ -1207,50 +1261,53 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                }
        }
 
                }
        }
 
-       public Object getIdentifier(Object entry, int i) {
+       @Override
+    public Object getIdentifier(Object entry, int i) {
                throw new UnsupportedOperationException();
        }
 
                throw new UnsupportedOperationException();
        }
 
-       public Object getOwner() {
+       @Override
+    public Object getOwner() {
                return owner;
        }
 
                return owner;
        }
 
-       public void setOwner(Object owner) {
+       @Override
+    public void setOwner(Object owner) {
                this.owner = owner;
        }
 
        /** ------ Below is section of code which makes remote service calls ----- */
                this.owner = owner;
        }
 
        /** ------ Below is section of code which makes remote service calls ----- */
-       // The affected methods are : 
+       // The affected methods are :
        // initialize(final boolean writing)
        // readSize()
        // readIndexExistence(final Object index)
        // readElementExistence(final Object element)
        // initialize(final boolean writing)
        // readSize()
        // readIndexExistence(final Object index)
        // readElementExistence(final Object element)
-       // readElementByIndex(final Object index) 
-       
+       // readElementByIndex(final Object index)
+
        private static ICdmApplicationConfiguration configuration;
        private static boolean remoting = false;
        private static ICdmApplicationConfiguration configuration;
        private static boolean remoting = false;
-       
+
        public static void setConfiguration(ICdmApplicationConfiguration conf) {
                configuration = conf;
        public static void setConfiguration(ICdmApplicationConfiguration conf) {
                configuration = conf;
-                       
+
                if(conf instanceof CdmApplicationRemoteController) {
                        remoting = true;
                } else {
                        remoting = false;
                }
        }
                if(conf instanceof CdmApplicationRemoteController) {
                        remoting = true;
                } else {
                        remoting = false;
                }
        }
-       
-       
+
+
        private void remoteInitialize() {
        private void remoteInitialize() {
-               
-               if (getOwner() != null && !initialized) {                       
-                       
+
+               if (getOwner() != null && !initialized) {
+
                        try {
                                String role = getRole();
                                String fieldName = role.substring(role.lastIndexOf(".") + 1);
                                log.info("--> Remote Lazy Initializing " + getRole() + " , key : " + getKey() + " , field : " + fieldName);
                                Object owner = getOwner();
                        try {
                                String role = getRole();
                                String fieldName = role.substring(role.lastIndexOf(".") + 1);
                                log.info("--> Remote Lazy Initializing " + getRole() + " , key : " + getKey() + " , field : " + fieldName);
                                Object owner = getOwner();
-                               
+
                                if(configuration == null) {
                                        throw new HibernateException("CdmApplicationRemoteConfiguration not initialized (null)");
                                }
                                if(configuration == null) {
                                        throw new HibernateException("CdmApplicationRemoteConfiguration not initialized (null)");
                                }
@@ -1258,24 +1315,25 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                                if(commonService == null) {
                                        throw new HibernateException("commonService not initialized (null)");
                                }
                                if(commonService == null) {
                                        throw new HibernateException("commonService not initialized (null)");
                                }
-                               
-                               PersistentCollection col = commonService.initializeCollection(this); 
-                               afterInitialize();
-
-                               Class<?> clazz = getClass();
-                               if (clazz != null) {    
-                                       CollectionField cf = getCollectionField(col);
-                                       Field field = clazz.getDeclaredField(cf.getFieldName());
-                                       field.setAccessible(true);
-                                       field.set(this, cf.getCollection());                           
-                               }               
+
+//                             PersistentCollection col = commonService.initializeCollection(this);
+//                             afterInitialize();
+//
+//                             Class<?> clazz = getClass();
+//                             if (clazz != null) {
+//                                     CollectionField cf = getCollectionField(col);
+//                                     Field field = clazz.getDeclaredField(cf.getFieldName());
+//                                     field.setAccessible(true);
+//                                     field.set(this, cf.getCollection());
+//                             }
                        } catch (Exception ex) {
                                log.warn(ex.getMessage());
                        } catch (Exception ex) {
                                log.warn(ex.getMessage());
-                       }                       
+                       }
+                       log.warn("This code is invalid");
                }
        }
                }
        }
-       
-       
+
+
        private CollectionField getCollectionField(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet) {
        private CollectionField getCollectionField(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet) {
@@ -1296,12 +1354,12 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                }
                return null;
        }
                }
                return null;
        }
-       
+
        private String getCollectionFieldName(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet || pc instanceof PersistentSortedSet) {
                                return "set";
        private String getCollectionFieldName(PersistentCollection pc) {
                if(pc != null) {
                        if(pc instanceof PersistentSet || pc instanceof PersistentSortedSet) {
                                return "set";
-                       }                       
+                       }
                        if(pc instanceof PersistentList) {
                                return "list";
                        }
                        if(pc instanceof PersistentList) {
                                return "list";
                        }
@@ -1311,59 +1369,36 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
                }
                return null;
        }
                }
                return null;
        }
-       
+
        private class CollectionField {
        private class CollectionField {
-               private Object col;
-               private String fieldName;
+               private final Object col;
+               private final String fieldName;
                public CollectionField(Object col, String fieldName) {
                        this.col = col;
                        this.fieldName = fieldName;
                }
                public CollectionField(Object col, String fieldName) {
                        this.col = col;
                        this.fieldName = fieldName;
                }
-               
+
                public Object getCollection() {
                        return this.col;
                }
                public Object getCollection() {
                        return this.col;
                }
-               
+
                public String getFieldName() {
                        return this.fieldName;
                }
        }
                public String getFieldName() {
                        return this.fieldName;
                }
        }
-       
+
        public static boolean isInitialized(List list) {
                return ((AbstractPersistentCollection)list).initialized;
        }
        public static boolean isInitialized(List list) {
                return ((AbstractPersistentCollection)list).initialized;
        }
-       
+
        public static boolean isInitialized(Map map) {
                return ((AbstractPersistentCollection)map).initialized;
        }
        public static boolean isInitialized(Map map) {
                return ((AbstractPersistentCollection)map).initialized;
        }
-       
+
        public static boolean isInitialized(Set set) {
                return ((AbstractPersistentCollection)set).initialized;
        }
        public static boolean isInitialized(Set set) {
                return ((AbstractPersistentCollection)set).initialized;
        }
-       
-       //FIXME:Remoting These methods may no longer be required since we are 
-       //               initialising collections as default behaviour
-       private int remoteSize() {
-               int size = configuration.getCommonService().size(this);
-               log.debug("--> Remote Lazy Initializing size of " + getRole() + " to " + size);
-               if(size == -1) {
-                       throw new HibernateException("size of " + getClass() + " could not be retrieved from remote service");
-               }
-               return size;
-       }
-       
-       private Object remoteReadElementByIndex(int index) {
-               Object element = configuration.getCommonService().get(this,index);
-               log.debug("--> Remote Lazy Initializing element from " + getRole() + " at index " + index);
-               return element;
-       }
-       
-       private boolean remoteReadElementExistence(Object element) {
-               return configuration.getCommonService().contains(this,element);
-       }
-       
-       private boolean remoteReadIndexExistence(Object index) {
-               return false;
-       }
+
+
 }
 
 }