openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r1331051 [2/5] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/ openjpa-...
Date Thu, 26 Apr 2012 19:53:51 GMT
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedProxy.java?rev=1331051&r1=1331050&r2=1331051&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedProxy.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedProxy.java Thu Apr 26 19:53:49 2012
@@ -21,23 +21,64 @@ package org.apache.openjpa.util;
 import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 
+/**
+ * Implemented by proxy classes which are delay-load capable. Delay-load
+ * proxies are lazily loaded and provide some operations
+ * which allow manipulation of proxy without necessarily needing to
+ * load the proxied object. 
+ */
 public interface DelayedProxy {
     
+    /**
+     * Load the proxy if it was delay-loaded.
+     */
     void load();
 
+    /**
+     * Returns whether the caller has direct-call access to the proxied
+     * object.  Direct access allows calls to be made on the object
+     * without triggering a load or proxy state tracking callbacks. 
+     */
     boolean isDirectAccess();
     
+    /**
+     * Sets whether the caller has direct-call access to the proxied
+     * object.  Direct access allows calls to be made on the object
+     * without triggering a load or proxy state tracking callbacks. 
+     */
     void setDirectAccess(boolean direct);
-    
+        
+    /**
+     * Get the broker that is used to service this proxy.
+     */
     Broker getBroker();
 
+    /**
+     * Close the broker that is used to service this proxy.
+     */
     void closeBroker();
 
+    /**
+     * Returns the state manager of the owning instance.
+     */
     OpenJPAStateManager getOwnerStateManager();
     
+    /**
+     * Returns a state manager that can service this proxy even if
+     * the collection was detached.
+     */
     OpenJPAStateManager getDelayedOwner();
     
+    /**
+     * Returns the expected field index even if this collection
+     * was detached.
+     * @return
+     */
     int getDelayedField();
     
+    /**
+     * Returns whether the proxy is detached.
+     * @return
+     */
     boolean isDetached();
 }

Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedTreeSetProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedTreeSetProxy.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedTreeSetProxy.java (added)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedTreeSetProxy.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.util;
+
+import java.io.ObjectStreamException;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.NavigableSet;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.openjpa.kernel.AutoDetach;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.BrokerFactory;
+import org.apache.openjpa.kernel.DetachedStateManager;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+
+/**
+ * TreeSet proxy with delay loading capability.  Allows non-indexed
+ * add and remove operations to occur on an unloaded collection.  Operations
+ * that require a load will trigger a load.
+ */
+@SuppressWarnings({"rawtypes","unchecked"})
+public class DelayedTreeSetProxy extends TreeSet implements ProxyCollection, DelayedProxy {
+    private transient OpenJPAStateManager sm;
+    private transient int field;
+    private transient CollectionChangeTracker changeTracker;
+    private transient Class elementType;
+
+    private transient OpenJPAStateManager _ownerSm;
+    private transient boolean _directAccess = false;
+    private transient BrokerFactory _brokerFactory = null;
+    private transient Broker _broker = null;
+    private transient OpenJPAStateManager _delayedSm;
+    private transient int _delayedField; 
+    private transient boolean _detached = false;
+    
+    public DelayedTreeSetProxy() {
+    }
+
+    public DelayedTreeSetProxy(Comparator paramComparator) {
+        super(paramComparator);
+    }
+
+    public DelayedTreeSetProxy(Collection paramCollection) {
+        super(paramCollection);
+    }
+
+    public DelayedTreeSetProxy(SortedSet paramSortedSet) {
+        super(paramSortedSet);
+    }
+
+    public void setOwner(OpenJPAStateManager paramOpenJPAStateManager, int paramInt)
+    {
+      // If clearing the owner of this proxy, store away what is necessary for 
+      // delayed loading 
+      if (sm != null && detaching(paramOpenJPAStateManager, paramInt)) {
+          _detached = true;
+          _delayedSm = sm;
+          _delayedField = field;
+      } else {
+          _detached = false;
+      }
+      
+      this.sm = paramOpenJPAStateManager;
+      if (sm != null && sm.getPersistenceCapable() != null) {
+          _ownerSm = (OpenJPAStateManager) sm.getPersistenceCapable().pcGetStateManager();
+      }
+      this.field = paramInt;
+      if (sm != null && sm.getContext() != null) {
+          _brokerFactory = sm.getContext().getBroker().getBrokerFactory();
+      }
+    }
+    
+    private boolean detaching(OpenJPAStateManager paramOpenJPAStateManager, int paramInt) {
+        if ((paramOpenJPAStateManager == null && paramInt == -1) || 
+            (paramOpenJPAStateManager != null && paramOpenJPAStateManager instanceof DetachedStateManager)) {
+            return true;
+        }
+        return false;
+    }
+
+    public OpenJPAStateManager getOwner() {
+        return this.sm;
+    }
+
+    public int getOwnerField() {
+        return this.field;
+    }
+
+    public ChangeTracker getChangeTracker() {
+        return this.changeTracker;
+    }
+
+    public Object copy(Object paramObject) {
+        return new TreeSet((SortedSet) paramObject);
+    }
+
+    public Class getElementType() {
+        return this.elementType;
+    }
+
+    public ProxyCollection newInstance(Class paramClass,
+            Comparator paramComparator, boolean paramBoolean1,
+            boolean paramBoolean2) {
+        DelayedTreeSetProxy localproxy = new DelayedTreeSetProxy(
+                paramComparator);
+        localproxy.elementType = paramClass;
+        if (paramBoolean1)
+            localproxy.changeTracker = new DelayedCollectionChangeTrackerImpl(
+                    localproxy, false, false, paramBoolean2);
+        return localproxy;
+    }
+
+    @Override
+    public Object clone() {
+        if (_directAccess) {
+            return super.clone();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        Proxy localProxy = (Proxy) super.clone();
+        localProxy.setOwner(null, 0);
+        return localProxy;
+    }
+
+
+    protected Object writeReplace() throws ObjectStreamException {
+        if (isDelayLoad()) {
+            load();
+        }
+        return Proxies.writeReplace(this, true);
+    }
+    
+    ////////////////////////////////////////
+    // DelayedProxy methods
+    ////////////////////////////////////////
+    public int getDelayedField() {
+        if (field == -1 || _detached) {
+            return _delayedField;
+        }
+        return field;
+    }
+    
+    public OpenJPAStateManager getDelayedOwner() {
+        if (sm == null || _detached) {
+            return _delayedSm;
+        }
+        return sm;
+    }
+
+    public boolean isDirectAccess() {
+        return _directAccess;
+    }
+    
+    public void setDirectAccess(boolean direct) {
+        _directAccess = direct;
+    }
+    
+    public BrokerFactory getBrokerFactory() {
+        return _brokerFactory;
+    }
+
+    @Override
+    public void load() {
+        ProxyCollections.loadCollection(this);
+    }
+
+    @Override
+    public Broker getBroker() {
+      if (_broker == null || _broker.isClosed()) {
+          if (_brokerFactory != null) {
+              _broker = _brokerFactory.newBroker();
+          }
+      }
+      return _broker;
+    }
+    
+    @Override
+    public void closeBroker() {
+        if (_broker != null && !_broker.isClosed()) {
+            _broker.setAutoDetach(AutoDetach.DETACH_CLOSE);
+            _broker.close();
+            _broker = null;
+        }
+    }
+
+    @Override
+    public OpenJPAStateManager getOwnerStateManager() {
+      return _ownerSm;
+    }
+    
+    @Override
+    public boolean isDetached() {
+        return _detached;
+    }
+
+    public boolean isDelayLoad() {
+        return ProxyCollections.isDelayed(this);
+    }
+
+    ////////////////////////////////////////
+    // TreeSet methods
+    ////////////////////////////////////////
+
+    @Override
+    public void clear() {
+        if (!_directAccess) {
+            if (isDelayLoad()) {
+                load();
+            }
+            ProxyCollections.beforeClear(this);
+        }
+        super.clear();
+    }
+
+    @Override
+    public Iterator iterator() {
+        if (_directAccess) {
+            return super.iterator();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        Iterator localIterator = super.iterator();
+        return ProxyCollections.afterIterator(this, localIterator);
+    }
+
+    @Override
+    public boolean remove(Object paramObject) {
+        if (_directAccess) {
+            return super.remove(paramObject);
+        }
+        ProxyCollections.beforeRemove(this, paramObject);
+        setDirectAccess(true);
+        boolean bool = super.remove(paramObject);
+        setDirectAccess(false);
+        return ProxyCollections.afterRemove(this, paramObject, bool);
+    }
+
+    @Override
+    public int size() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.isEmpty();
+    }
+
+    @Override
+    public boolean contains(Object object) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.contains(object);
+    }
+
+    @Override
+    public Object[] toArray() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.toArray();
+    }
+
+    @Override
+    public Object[] toArray(Object[] array) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.toArray(array);
+    }
+
+    @Override
+    public Comparator comparator() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.comparator();
+    }
+
+    @Override
+    public Object first() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.first();
+    }
+
+    @Override
+    public Object last() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.last();
+    }
+
+    @Override
+    public boolean add(Object paramObject) {
+        if (_directAccess) {
+            return super.add(paramObject);
+        }
+        ProxyCollections.beforeAdd(this, paramObject);
+        boolean bool = super.add(paramObject);
+        return ProxyCollections.afterAdd(this, paramObject, bool);
+    }
+
+    @Override
+    public boolean containsAll(Collection c) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.addAll(paramCollection);
+        }
+        return ProxyCollections.addAll(this, paramCollection);
+    }
+
+    @Override
+    public boolean retainAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.retainAll(paramCollection);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        return ProxyCollections.retainAll(this, paramCollection);
+    }
+
+    @Override
+    public boolean removeAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.removeAll(paramCollection);
+        }
+        return ProxyCollections.removeAll(this, paramCollection);
+    }
+
+    @Override
+    public Object lower(Object e) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.lower(e);
+    }
+
+    @Override
+    public Object floor(Object e) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.floor(e);
+    }
+
+    @Override
+    public Object ceiling(Object e) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.ceiling(e);
+    }
+
+    @Override
+    public Object higher(Object e) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.higher(e);
+    }
+
+    @Override
+    public Object pollFirst() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.pollFirst();
+    }
+
+    @Override
+    public Object pollLast() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.pollLast();
+    }
+
+    @Override
+    public NavigableSet descendingSet() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.descendingSet();
+    }
+
+    @Override
+    public Iterator descendingIterator() {
+        if (_directAccess) {
+            return super.descendingIterator();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        Iterator localIterator = super.descendingIterator();
+        return ProxyCollections.afterIterator(this, localIterator);
+    }
+
+    @Override
+    public NavigableSet subSet(Object fromElement, boolean fromInclusive,
+            Object toElement, boolean toInclusive) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.subSet(fromElement, fromInclusive, toElement, toInclusive);
+    }
+
+    @Override
+    public NavigableSet headSet(Object toElement, boolean inclusive) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.headSet(toElement, inclusive);
+    }
+
+    @Override
+    public NavigableSet tailSet(Object fromElement, boolean inclusive) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.tailSet(fromElement, inclusive);
+    }
+
+    @Override
+    public SortedSet subSet(Object fromElement, Object toElement) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.subSet(fromElement, toElement);
+    }
+
+    @Override
+    public SortedSet headSet(Object toElement) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.headSet(toElement);
+    }
+
+    @Override
+    public SortedSet tailSet(Object fromElement) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.tailSet(fromElement);
+    }
+    
+    @Override
+    public boolean equals(Object paramObject) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.equals(paramObject);
+    }
+
+    @Override
+    public int hashCode() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.hashCode();
+    }
+}

Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedTreeSetProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedVectorProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedVectorProxy.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedVectorProxy.java (added)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedVectorProxy.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,653 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.util;
+
+import java.io.ObjectStreamException;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.apache.openjpa.kernel.AutoDetach;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.BrokerFactory;
+import org.apache.openjpa.kernel.DetachedStateManager;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+
+/**
+ * Vector proxy with delay loading capability.  Allows non-indexed
+ * add and remove operations to occur on an unloaded collection.  Operations
+ * that require a load will trigger a load.
+ */
+@SuppressWarnings({"rawtypes","unchecked"})
+public class DelayedVectorProxy extends Vector implements ProxyCollection, DelayedProxy {
+    private transient OpenJPAStateManager sm;
+    private transient int field;
+    private transient CollectionChangeTracker changeTracker;
+    private transient Class elementType;
+
+    private transient OpenJPAStateManager _ownerSm;
+    private transient boolean _directAccess = false;
+    private transient BrokerFactory _brokerFactory = null;
+    private transient Broker _broker = null;
+    private transient OpenJPAStateManager _delayedSm;
+    private transient int _delayedField;
+    private transient boolean _detached = false;
+
+    public DelayedVectorProxy(int paramInt) {
+        super(paramInt);
+    }
+
+    public DelayedVectorProxy() {
+    }
+
+    public DelayedVectorProxy(Collection paramCollection) {
+        super(paramCollection);
+    }
+
+    public DelayedVectorProxy(int paramInt1, int paramInt2) {
+        super(paramInt1, paramInt2);
+    }
+
+    @Override
+    public void setOwner(OpenJPAStateManager paramOpenJPAStateManager,
+            int paramInt) {
+        // If clearing the owner of this proxy, store away what is necessary for
+        // delayed loading
+        if (sm != null && detaching(paramOpenJPAStateManager, paramInt)) {
+            _detached = true;
+            _delayedSm = sm;
+            _delayedField = field;
+        } else {
+            _detached = false;
+        }
+
+        this.sm = paramOpenJPAStateManager;
+        if (sm != null && sm.getPersistenceCapable() != null) {
+            _ownerSm = (OpenJPAStateManager) sm.getPersistenceCapable()
+                    .pcGetStateManager();
+        }
+        this.field = paramInt;
+        if (sm != null && sm.getContext() != null) {
+            _brokerFactory = sm.getContext().getBroker().getBrokerFactory();
+        }
+    }
+
+    private boolean detaching(OpenJPAStateManager paramOpenJPAStateManager,
+            int paramInt) {
+        if ((paramOpenJPAStateManager == null && paramInt == -1)
+                || (paramOpenJPAStateManager != null && paramOpenJPAStateManager instanceof DetachedStateManager)) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public int getDelayedField() {
+        if (field == -1 || _detached) {
+            return _delayedField;
+        }
+        return field;
+    }
+
+    @Override
+    public OpenJPAStateManager getDelayedOwner() {
+        if (sm == null || _detached) {
+            return _delayedSm;
+        }
+        return sm;
+    }
+
+    @Override
+    public OpenJPAStateManager getOwner() {
+        return this.sm;
+    }
+
+    @Override
+    public int getOwnerField() {
+        return this.field;
+    }
+
+    @Override
+    public boolean isDirectAccess() {
+        return _directAccess;
+    }
+
+    @Override
+    public void setDirectAccess(boolean direct) {
+        _directAccess = direct;
+    }
+
+    public BrokerFactory getBrokerFactory() {
+        return _brokerFactory;
+    }
+
+    @Override
+    public void load() {
+        ProxyCollections.loadCollection(this);
+    }
+
+    @Override
+    public Broker getBroker() {
+        if (_broker == null || _broker.isClosed()) {
+            if (_brokerFactory != null) {
+                _broker = _brokerFactory.newBroker();
+            }
+        }
+        return _broker;
+    }
+
+    @Override
+    public void closeBroker() {
+        if (_broker != null && !_broker.isClosed()) {
+            _broker.setAutoDetach(AutoDetach.DETACH_CLOSE);
+            _broker.close();
+            _broker = null;
+        }
+    }
+
+    @Override
+    public OpenJPAStateManager getOwnerStateManager() {
+        return _ownerSm;
+    }
+
+    @Override
+    public boolean isDetached() {
+        return _detached;
+    }
+
+    public boolean isDelayLoad() {
+        return ProxyCollections.isDelayed(this);
+    }
+
+    @Override
+    public synchronized Object clone() {
+        if (isDirectAccess()) {
+            return super.clone();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+
+        Proxy localProxy = (Proxy) super.clone();
+        localProxy.setOwner(null, 0);
+        return localProxy;
+    }
+
+    @Override
+    public ChangeTracker getChangeTracker() {
+        return this.changeTracker;
+    }
+
+    @Override
+    public Object copy(Object paramObject) {
+        if (isDelayLoad()) {
+            load();
+        }
+        return new Vector((Collection) paramObject);
+    }
+
+    @Override
+    public Class getElementType() {
+        return this.elementType;
+    }
+
+    @Override
+    public ProxyCollection newInstance(Class paramClass,
+            Comparator paramComparator, boolean paramBoolean1,
+            boolean paramBoolean2) {
+        DelayedVectorProxy localproxy = new DelayedVectorProxy();
+        localproxy.elementType = paramClass;
+        if (paramBoolean1) {
+            localproxy.changeTracker = new DelayedCollectionChangeTrackerImpl(
+                    localproxy, true, true, paramBoolean2);
+        }
+        return localproxy;
+    }
+
+    @Override
+    public synchronized boolean add(Object paramObject) {
+        if (_directAccess) {
+            return super.add(paramObject);
+        }
+
+        ProxyCollections.beforeAdd(this, paramObject);
+        boolean bool = super.add(paramObject);
+        return ProxyCollections.afterAdd(this, paramObject, bool);
+    }
+
+    @Override
+    public synchronized void add(int paramInt, Object paramObject) {
+        if (!_directAccess) {
+            if (isDelayLoad()) {
+                load();
+            }
+        }
+        ProxyCollections.beforeAdd(this, paramInt, paramObject);
+        super.add(paramInt, paramObject);
+    }
+
+    @Override
+    public void clear() {
+        if (!_directAccess) {
+            if (isDelayLoad()) {
+                load();
+            }
+            ProxyCollections.beforeClear(this);
+        }
+        super.clear();
+    }
+
+    @Override
+    public synchronized boolean addAll(int paramInt, Collection paramCollection) {
+        if (_directAccess) {
+            return super.addAll(paramInt, paramCollection);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        return ProxyCollections.addAll(this, paramInt, paramCollection);
+    }
+
+    @Override
+    public synchronized boolean addAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.addAll(paramCollection);
+        }
+        return ProxyCollections.addAll(this, paramCollection);
+    }
+
+    @Override
+    public synchronized void addElement(Object paramObject) {
+        if (_directAccess) {
+            super.addElement(paramObject);
+            return;
+        }
+
+        ProxyCollections.beforeAddElement(this, paramObject);
+        super.addElement(paramObject);
+        ProxyCollections.afterAddElement(this, paramObject);
+    }
+
+    @Override
+    public synchronized Object remove(int paramInt) {
+        if (_directAccess) {
+            return super.remove(paramInt);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+
+        ProxyCollections.beforeRemove(this, paramInt);
+        Object localObject = super.remove(paramInt);
+        return ProxyCollections.afterRemove(this, paramInt, localObject);
+    }
+
+    @Override
+    public synchronized boolean remove(Object paramObject) {
+        if (_directAccess) {
+            return super.remove(paramObject);
+        }
+        ProxyCollections.beforeRemove(this, paramObject);
+        setDirectAccess(true);
+        boolean bool = super.remove(paramObject);
+        setDirectAccess(false);
+        return ProxyCollections.afterRemove(this, paramObject, bool);
+    }
+
+    @Override
+    public synchronized Object set(int paramInt, Object paramObject) {
+        if (_directAccess) {
+            return super.set(paramInt, paramObject);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ProxyCollections.beforeSet(this, paramInt, paramObject);
+        Object localObject = super.set(paramInt, paramObject);
+        return ProxyCollections.afterSet(this, paramInt, paramObject,
+                localObject);
+    }
+
+    @Override
+    public synchronized boolean removeAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.removeAll(paramCollection);
+        }
+        return ProxyCollections.removeAll(this, paramCollection);
+    }
+
+    @Override
+    public synchronized boolean retainAll(Collection paramCollection) {
+        if (_directAccess) {
+            return super.retainAll(paramCollection);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        return ProxyCollections.retainAll(this, paramCollection);
+    }
+
+    @Override
+    public synchronized void insertElementAt(Object paramObject, int paramInt) {
+        if (_directAccess) {
+            super.insertElementAt(paramObject, paramInt);
+            return;
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+
+        ProxyCollections.beforeInsertElementAt(this, paramObject, paramInt);
+        super.insertElementAt(paramObject, paramInt);
+    }
+
+    @Override
+    public synchronized void removeAllElements() {
+        if (_directAccess) {
+            super.removeAllElements();
+            return;
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ProxyCollections.beforeRemoveAllElements(this);
+        super.removeAllElements();
+    }
+
+    @Override
+    public synchronized boolean removeElement(Object paramObject) {
+        if (_directAccess) {
+            return super.removeElement(paramObject);
+        }
+        ProxyCollections.beforeRemoveElement(this, paramObject);
+        setDirectAccess(true);
+        boolean bool = super.removeElement(paramObject);
+        setDirectAccess(false);
+        return ProxyCollections.afterRemoveElement(this, paramObject, bool);
+    }
+
+    @Override
+    public synchronized void removeElementAt(int paramInt) {
+        if (_directAccess) {
+            super.removeElementAt(paramInt);
+            return;
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ProxyCollections.beforeRemoveElementAt(this, paramInt);
+        super.removeElementAt(paramInt);
+    }
+
+    @Override
+    public synchronized void setElementAt(Object paramObject, int paramInt) {
+        if (_directAccess) {
+            super.setElementAt(paramObject, paramInt);
+            return;
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ProxyCollections.beforeSetElementAt(this, paramObject, paramInt);
+        super.setElementAt(paramObject, paramInt);
+    }
+
+    @Override
+    public Iterator iterator() {
+        if (_directAccess) {
+            return super.iterator();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        Iterator localIterator = super.iterator();
+        return ProxyCollections.afterIterator(this, localIterator);
+    }
+
+    @Override
+    public ListIterator listIterator(int paramInt) {
+        if (_directAccess) {
+            return super.listIterator(paramInt);
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ListIterator localListIterator = super.listIterator(paramInt);
+        return ProxyCollections.afterListIterator(this, paramInt,
+                localListIterator);
+    }
+
+    @Override
+    public ListIterator listIterator() {
+        if (_directAccess) {
+            return super.listIterator();
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        ListIterator localListIterator = super.listIterator();
+        return ProxyCollections.afterListIterator(this, localListIterator);
+    }
+
+    @Override
+    public synchronized void setSize(int paramInt) {
+        if (_directAccess) {
+            super.setSize(paramInt);
+            return;
+        }
+        if (isDelayLoad()) {
+            load();
+        }
+        Proxies.dirty(this, true);
+        super.setSize(paramInt);
+    }
+
+    protected synchronized Object writeReplace() throws ObjectStreamException {
+        if (isDelayLoad()) {
+            load();
+        }
+        return Proxies.writeReplace(this, true);
+    }
+
+    @Override
+    public synchronized boolean contains(Object object) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.contains(object);
+    }
+
+    @Override
+    public synchronized boolean containsAll(Collection collection) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.containsAll(collection);
+    }
+
+    @Override
+    public synchronized boolean isEmpty() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.isEmpty();
+    }
+
+    @Override
+    public synchronized int size() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.size();
+    }
+
+    @Override
+    public synchronized Object[] toArray() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.toArray();
+    }
+
+    @Override
+    public synchronized Object[] toArray(Object[] array) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.toArray(array);
+    }
+
+    @Override
+    public synchronized boolean equals(Object paramObject) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.equals(paramObject);
+    }
+
+    @Override
+    public synchronized int hashCode() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.hashCode();
+    }
+
+    @Override
+    public synchronized int lastIndexOf(Object object) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.lastIndexOf(object);
+    }
+
+    @Override
+    public synchronized List subList(int start, int end) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.subList(start, end);
+    }
+
+    @Override
+    public synchronized Object get(int location) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.get(location);
+    }
+
+    @Override
+    public synchronized int indexOf(Object object) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.indexOf(object);
+    }
+
+    @Override
+    public synchronized int indexOf(Object object, int index) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.indexOf(object, index);
+    }
+
+    @Override
+    public synchronized void copyInto(Object[] anArray) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        super.copyInto(anArray);
+    }
+
+    public synchronized void trimToSize() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        super.trimToSize();
+    }
+
+    public synchronized void ensureCapacity(int minCapacity) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        super.ensureCapacity(minCapacity);
+    }
+
+    public synchronized int capacity() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.capacity();
+    }
+
+    public Enumeration elements() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.elements();
+    }
+
+    public synchronized int lastIndexOf(Object o, int index) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.lastIndexOf(o, index);
+    }
+
+    public synchronized Object elementAt(int index) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.elementAt(index);
+    }
+
+    public synchronized Object firstElement() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.firstElement();
+    }
+
+    public synchronized Object lastElement() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.lastElement();
+    }
+
+    public synchronized String toString() {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        return super.toString();
+    }
+
+    protected synchronized void removeRange(int fromIndex, int toIndex) {
+        if (!_directAccess && isDelayLoad()) {
+            load();
+        }
+        super.removeRange(fromIndex, toIndex);
+    }
+}

Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/DelayedVectorProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java?rev=1331051&r1=1331050&r2=1331051&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java Thu Apr 26 19:53:49 2012
@@ -497,14 +497,43 @@ public class ProxyManagerImpl
      */
     protected Class loadBuildTimeProxy(Class type, ClassLoader loader) {
         try {
-            if (_delayedCollectionLoading && type.equals(java.util.ArrayList.class)) {
-                return org.apache.openjpa.util.DelayedArrayListProxy.class;
+            Class<?> proxyClass = null;
+            if (_delayedCollectionLoading) {
+                proxyClass = loadDelayedProxy(type);
+                if (proxyClass != null) {
+                    return proxyClass;
+                }
             }
             return Class.forName(getProxyClassName(type, false), true, loader);
         } catch (Throwable t) {
             return null;
         }
     }
+    
+    protected Class<?> loadDelayedProxy(Class<?> type) {
+        if (type.equals(java.util.ArrayList.class)) {
+            return org.apache.openjpa.util.DelayedArrayListProxy.class;
+        }
+        if (type.equals(java.util.HashSet.class)) {
+            return org.apache.openjpa.util.DelayedHashSetProxy.class;
+        }
+        if (type.equals(java.util.LinkedList.class)) {
+            return org.apache.openjpa.util.DelayedLinkedListProxy.class;
+        }
+        if (type.equals(java.util.Vector.class)) {
+            return org.apache.openjpa.util.DelayedVectorProxy.class;
+        }
+        if (type.equals(java.util.LinkedHashSet.class)) {
+            return org.apache.openjpa.util.DelayedLinkedHashSetProxy.class;
+        }
+        if (type.equals(java.util.SortedSet.class) || type.equals(java.util.TreeSet.class)) {
+            return org.apache.openjpa.util.DelayedTreeSetProxy.class;
+        }
+        if (type.equals(java.util.PriorityQueue.class)) {
+            return org.apache.openjpa.util.DelayedPriorityQueueProxy.class;
+        }
+        return null;
+    }
 
     /**
      * Instantiate the given proxy class.

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Award.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Award.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Award.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Award.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.io.Serializable;
+
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class Award implements Serializable, Comparable<Award>{
+
+    private static final long serialVersionUID = -1110613520812966568L;
+
+    private String awdName;
+    
+    private String awdType;
+
+    public void setAwdName(String awdName) {
+        this.awdName = awdName;
+    }
+
+    public String getAwdName() {
+        return awdName;
+    }
+
+    public void setAwdType(String awdType) {
+        this.awdType = awdType;
+    }
+
+    public String getAwdType() {
+        return awdType;
+    }
+
+    @Override
+    public int compareTo(Award o) {
+        String nameType = awdName+awdType;
+        String nameType2 = o.getAwdName()+o.getAwdType();
+        return nameType.compareTo(nameType2);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Award.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Certification.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Certification.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Certification.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Certification.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Embeddable
+public class Certification  implements Serializable, Comparable<Certification> {
+
+    private static final long serialVersionUID = 4989402309885734073L;
+
+    private String name;
+    
+    private String level;
+    
+    @Temporal(TemporalType.DATE)
+    private Date certDate;
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setCertDate(Date certDate) {
+        this.certDate = certDate;
+    }
+
+    public Date getCertDate() {
+        return certDate;
+    }
+
+    @Override
+    public int compareTo(Certification o) {
+        String nameLevelDate = name+level+certDate;
+        String nameLevelDate2 = o.getName()+o.getLevel()+o.getCertDate();
+        return nameLevelDate.compareTo(nameLevelDate2);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Certification.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/DelayedProxyCollectionsTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/DelayedProxyCollectionsTestCase.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/DelayedProxyCollectionsTestCase.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/DelayedProxyCollectionsTestCase.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,810 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.kernel.DetachedStateManager;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+import org.apache.openjpa.util.DelayedProxy;
+import org.apache.openjpa.util.Proxy;
+import org.apache.openjpa.util.ProxyCollection;
+
+/**
+ * Verifies generic delay-load capabilities for delay-load collection proxies.
+ */
+public abstract class DelayedProxyCollectionsTestCase extends SQLListenerTestCase {
+    
+    protected static Set<String> _ignoreMethods;
+    protected static Set<String> _delayMethods;
+    protected static Set<Class<?>> _ignoreInterfaces;
+    
+    public void setUp(Object...props) {
+        List<Object> parms = new ArrayList<Object>();
+        parms.addAll(Arrays.asList(
+                CLEAR_TABLES,
+                "openjpa.ProxyManager", "delayCollectionLoading=true",
+                Award.class, 
+                Location.class,
+                Product.class,
+                Certification.class));
+        parms.addAll(Arrays.asList(props));
+        super.setUp(parms.toArray());
+    }
+    
+    public abstract IAccount createAccount(String name, IUserIdentity ui);
+    public abstract IDepartment createDepartment();
+    public abstract IDepartment findDepartment(EntityManager em, int id);
+    public abstract IEmployee createEmployee();
+    public abstract Collection<IEmployee> createEmployees();
+    public abstract IMember createMember(String name);
+    public abstract IUserIdentity findUserIdentity(EntityManager em, int id);
+    public abstract IUserIdentity createUserIdentity();
+    public abstract Collection<Product> createProducts();
+    public abstract Collection<Certification> createCertifications();
+    public abstract IEmployee getEmployee(Collection<IEmployee> emps, int idx);
+    public abstract Collection<Award> createAwards();
+    public abstract Product getProduct(Collection<Product> products, int idx);
+    public abstract Collection<Location> createLocations();
+    public abstract Collection<IAccount> createAccounts();
+
+    static {
+        // non-indexed delay-capable methods
+        _delayMethods = new HashSet<String>();
+        // generic collection
+        _delayMethods.add(stringMethodName("add", new Class<?>[] {Object.class}));
+        _delayMethods.add(stringMethodName("remove", new Class<?>[] {Object.class}));
+        _delayMethods.add(stringMethodName("removeAll", new Class<?>[] {Collection.class}));
+        _delayMethods.add(stringMethodName("addAll", new Class<?>[] {Collection.class}));
+        // queue
+        _delayMethods.add(stringMethodName("offer", new Class<?>[] {Object.class}));
+        // vector
+        _delayMethods.add(stringMethodName("addElement", new Class<?>[] {Object.class}));
+        _delayMethods.add(stringMethodName("removeElement", new Class<?>[] {Object.class}));
+
+        // non-trigger methods
+        _ignoreMethods = new HashSet<String>();
+        _ignoreMethods.add(stringMethodName("trimToSize", null));
+        _ignoreMethods.add(stringMethodName("ensureCapacity", new Class<?>[] {int.class}));
+        _ignoreMethods.add(stringMethodName("comparator", null));
+        
+        // non-trigger base Object methods
+        _ignoreMethods.add(stringMethodName("wait", new Class<?>[] {long.class}));
+        _ignoreMethods.add(stringMethodName("wait", null));
+        _ignoreMethods.add(stringMethodName("wait", new Class<?>[] {long.class, int.class}));
+        _ignoreMethods.add(stringMethodName("getClass", null));
+        _ignoreMethods.add(stringMethodName("notify", null));
+        _ignoreMethods.add(stringMethodName("notifyAll", null));
+                
+        _ignoreInterfaces = new HashSet<Class<?>>();
+        _ignoreInterfaces.add(DelayedProxy.class);
+        _ignoreInterfaces.add(Proxy.class);
+        _ignoreInterfaces.add(ProxyCollection.class);
+    }
+
+    public static String stringMethodName(Method m) {
+        return stringMethodName(m.getName(), m.getParameterTypes());
+    }
+
+    public static String stringMethodName(String m, Class<?>[] types) {
+        StringBuilder sb = new StringBuilder(m);
+        if (types != null) {
+            for (Class<?> type : types) {
+                sb.append(":");
+                sb.append(type.getName());
+            }
+        }
+        return sb.toString();
+    }
+    
+    public Set<String> methodsToIgnore() {
+        return _ignoreMethods;
+    }
+
+    public Award createAward() {
+        Award a = new Award();
+        a.setAwdName("Employee of the Month " + new Random().nextInt(999999));
+        a.setAwdType("Certificate");
+        return a;
+    }
+
+    public Certification createCertification() {
+        Certification c = new Certification();
+        c.setName("Certification XYZ " + new Random().nextInt(999999));
+        c.setCertDate(new Date());
+        return c;
+    }
+
+    public Product createProduct() {
+        Product p = new Product();
+        p.setName("Product : " + new Random().nextInt(999999));
+        return p;
+    }
+
+    public Location createLocation() {
+        Location l = new Location();
+        l.setAddress(new Random().nextInt(9999) + " Wandering Way");
+        l.setCity("Somewhere");
+        l.setZip(Integer.toString(new Random().nextInt(99999)));
+        return l;
+    }
+    
+    /*
+     * Verify an element can be non-index removed from a delayed proxy collection
+     * without triggering a load of the collection.
+     */
+    public void testSingleRemove() {
+        
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and an employee
+        IDepartment d = createDepartment();
+        IEmployee e = createEmployee();
+        e.setDept(d);
+        e.setEmpName("John");
+        IEmployee e2 = createEmployee();
+        e2.setDept(d);
+        e2.setEmpName("Joe");
+        Collection<IEmployee> emps = createEmployees();
+        emps.add(e);
+        emps.add(e2);
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        em.clear();
+        
+        resetSQL();
+        d = findDepartment(em, d.getId());
+        // assert the select did not contain the employee table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertNotNull(d);
+        emps = d.getEmployees();
+        // assert there was no select
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertTrue(emps instanceof DelayedProxy);
+        DelayedProxy dep = (DelayedProxy)emps;
+        dep.setDirectAccess(true);
+        assertEquals(0, emps.size());
+        dep.setDirectAccess(false);
+        assertNotNull(emps);
+
+        // remove the employee from the collection
+        resetSQL();
+        em.getTransaction().begin();
+        emps.remove(e);
+        em.getTransaction().commit();
+        // assert the delete from the join table
+        assertAnySQLAnyOrder("DELETE FROM DC_DEP_EMP .*");
+        // assert no select from employee or dept table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEPARTMENT .*");
+        
+        // iterate the collection and assert a select from the employee table
+        // and that the expected entity is returned
+        resetSQL();
+        assertEquals(1, emps.size());
+        assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        IEmployee e3 = getEmployee(emps, 0);
+        assertEquals(e2, e3);
+        em.close();
+    }
+
+    /*
+     * Verify an element can be non-index added to a delayed proxy collection
+     * without triggering a load on the collection.
+     */
+    public void testSingleAdd() {
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and an employee
+        IDepartment d = createDepartment();
+        IEmployee e = createEmployee();
+        e.setDept(d);
+        e.setEmpName("John");
+        Collection<IEmployee> emps = createEmployees();
+        emps.add(e);
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        em.clear();
+        
+        resetSQL();
+        d = findDepartment(em, d.getId());
+        // assert the select did not contain the employee table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertNotNull(d);
+        emps = d.getEmployees();
+        // assert there was no select
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertTrue(emps instanceof DelayedProxy);
+        DelayedProxy dep = (DelayedProxy)emps;
+        dep.setDirectAccess(true);
+        assertEquals(0, emps.size());
+        dep.setDirectAccess(false);
+        assertNotNull(emps);
+
+        // add an employee to the collection
+        resetSQL();
+        em.getTransaction().begin();
+        IEmployee e2 = createEmployee();
+        e2.setDept(d);
+        e2.setEmpName("Joe");
+        emps.add(e2);
+        em.getTransaction().commit();
+        // assert the insert into the employee and join table
+        assertAnySQLAnyOrder("INSERT INTO DC_DEP_EMP .*");
+        assertAnySQLAnyOrder("INSERT INTO DC_EMPLOYEE .*");
+        // assert no select from employee or dept table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEPARTMENT .*");
+        
+        // call contains and assert a select from the employee table
+        // occurred that the expected entities are returned.
+        resetSQL();
+        assertTrue(emps.contains(e));
+        assertTrue(emps.contains(e2));
+        assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        resetSQL();
+        assertEquals(2, emps.size());
+        // verify a second SQL was not issued to get the size
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        em.close();
+    }
+    
+    /*
+     * Verify a mix of non-indexed add and remove operations can occur without
+     * triggering a load on a delayed collection. 
+     */
+    public void testMixedAddRemove() {
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and an employee
+        IDepartment d = createDepartment();
+        IEmployee e = createEmployee();
+        e.setDept(d);
+        e.setEmpName("John");
+        Collection<IEmployee> emps = createEmployees();
+        emps.add(e);
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        em.clear();
+        
+        resetSQL();
+        d = findDepartment(em, d.getId());
+        // assert the select did not contain the employee table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertNotNull(d);
+        emps = d.getEmployees();
+        // assert there was no select
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertTrue(emps instanceof DelayedProxy);
+        DelayedProxy dep = (DelayedProxy)emps;
+        dep.setDirectAccess(true);
+        assertEquals(0, emps.size());
+        dep.setDirectAccess(false);
+        assertNotNull(emps);
+
+        // add an employee to the collection and remove the same employee and commit
+        resetSQL();
+        em.getTransaction().begin();
+        IEmployee e2 = createEmployee();
+        e2.setDept(d);
+        e2.setEmpName("Joe");
+        emps.add(e2);
+        emps.remove(e2);
+        em.getTransaction().commit();
+        // assert the insert into the entity and join table
+        assertNoneSQLAnyOrder("INSERT INTO DC_DEP_EMP .*");
+        assertNoneSQLAnyOrder("INSERT INTO DC_EMPLOYEE .*");
+        // assert no select from employee or dept table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEPARTMENT .*");
+
+        // add two employees to the collection and remove one and commit
+        resetSQL();
+        em.getTransaction().begin();
+        IEmployee e3 = createEmployee();
+        e3.setDept(d);
+        e3.setEmpName("Rhonda");
+        emps.add(e3);
+
+        IEmployee e4 = createEmployee();
+        e4.setDept(d);
+        e4.setEmpName("Maria");
+        emps.add(e4);
+        emps.remove(e3);
+        em.getTransaction().commit();
+        // assert the insert into the employee and join table
+        assertAnySQLAnyOrder("INSERT INTO DC_DEP_EMP .*");
+        assertAnySQLAnyOrder("INSERT INTO DC_EMPLOYEE .*");
+        // assert no select from employee or dept table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEPARTMENT .*");
+
+        // call contains and assert a select from the employee table
+        // occurred that the expected entities are returned.
+        resetSQL();
+        assertTrue(emps.contains(e));
+        assertFalse(emps.contains(e2));
+        assertFalse(emps.contains(e3));
+        assertTrue(emps.contains(e4));
+        assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        resetSQL();
+        assertEquals(2, emps.size());
+        // verify a second SQL was not issued to get the size
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        em.close();
+    }
+
+    /*
+     * Verify that an eagerly loaded collection with delayed load enabled
+     * functions as expected.
+     */
+    public void testEagerCollection() {
+        EntityManager em = emf.createEntityManager();
+
+        // Create a new department and 
+        IDepartment d = createDepartment();
+        Collection<Product> products = createProducts();
+        
+        Product p = createProduct();
+        products.add(p);
+        Product p2 = createProduct();
+        products.add(p2);
+        d.setProducts(products);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        resetSQL();
+
+        em.clear();
+        
+        d = findDepartment(em, d.getId());
+        assertAnySQLAnyOrder("SELECT .* DC_DEP_PRD .*");
+        resetSQL();
+        products = d.getProducts();
+        assertTrue(products instanceof DelayedProxy);
+        ProxyCollection pxycoll = (ProxyCollection)products;
+        assertFalse(pxycoll.getOwner().isDelayed(pxycoll.getOwnerField()));
+        Product p3 = getProduct(products, 0);
+        assertTrue(products.contains(p3));
+        assertEquals(2, products.size());
+        assertNoneSQLAnyOrder("SELECT .* DC_DEPARTMENT .*", "SELECT .* DC_DEP_PRD .*");
+        em.close();
+    }
+    
+    /*
+     * Verify that a DB ordered collection is not delay load capable.
+     */
+    public void testOrderedCollection() {
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and persist
+        IDepartment d = createDepartment();
+        
+        Location l = createLocation();
+        Collection<Location> locs = createLocations();
+        locs.add(l);
+        d.setLocations(locs);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        
+        em.clear();
+        
+        d = findDepartment(em, d.getId());
+        assertNoneSQLAnyOrder("SELECT .* DC_DEP_LOC .*");
+        // verify that the collection is not delay loaded and does not trigger a load
+        resetSQL();
+        Collection<Location> locations = d.getLocations();
+        assertAnySQLAnyOrder("SELECT .* DC_DEP_LOC .*");
+        resetSQL();
+        assertTrue(locations instanceof DelayedProxy);
+        ProxyCollection pxycoll = (ProxyCollection)locations;
+        assertFalse(pxycoll.getOwner().isDelayed(pxycoll.getOwnerField()));
+        assertEquals(1, locations.size());
+        assertNoneSQLAnyOrder("SELECT .* DC_DEPARTMENT .*", "SELECT .* DC_DEP_LOC .*");
+        em.close();
+    }
+    
+    /*
+     * Verify that a collection will load upon serialization
+     */
+    public void testSerialization() {
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and an employee
+        IDepartment d = createDepartment();
+        IEmployee e = createEmployee();
+        e.setDept(d);
+        e.setEmpName("John");
+        Collection<IEmployee> emps = createEmployees();
+        emps.add(e);
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        em.clear();
+        
+        resetSQL();
+        d = findDepartment(em, d.getId());
+        // assert the select did not contain the employee table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertNotNull(d);
+        emps = d.getEmployees();
+        // assert there was no select
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertTrue(emps instanceof DelayedProxy);
+        DelayedProxy dep = (DelayedProxy)emps;
+        dep.setDirectAccess(true);
+        assertEquals(0, emps.size());
+        dep.setDirectAccess(false);
+        assertNotNull(emps);
+
+        // add an employee to the collection
+        resetSQL();
+        em.getTransaction().begin();
+        IEmployee e2 = createEmployee();
+        e2.setDept(d);
+        e2.setEmpName("Joe");
+        emps.add(e2);
+        em.getTransaction().commit();
+        // assert the insert into the employee and join table
+        assertAnySQLAnyOrder("INSERT INTO DC_DEP_EMP .*");
+        assertAnySQLAnyOrder("INSERT INTO DC_EMPLOYEE .*");
+        // assert no select from employee or dept table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEPARTMENT .*");
+        
+        resetSQL();
+        try {
+            // Serialize the department entity and verify the employee collection was loaded
+            IDepartment d2 = roundtrip(d);
+            assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*", "SELECT .* DC_DEP_EMP .*");
+            emps = d2.getEmployees();
+            assertTrue(emps.contains(e));
+            assertTrue(emps.contains(e2));
+            assertEquals(2, emps.size());
+        } catch (Exception ex) {
+            fail(ex.getMessage());
+        }
+        
+        em.close();
+    }
+    
+    /*
+     * Verify that a lazy collection of embeddables works as expected
+     * (delays load) with delayed loading enabled
+     */
+    public void testLazyEmbeddableCollection() {
+        EntityManager em = emf.createEntityManager();
+        
+        IDepartment d = createDepartment();
+        
+        Collection<Certification> certs = createCertifications();
+        certs.add(createCertification());
+        certs.add(createCertification());
+        d.setCertifications(certs);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        
+        resetSQL();
+
+        em.clear();
+        
+        d = findDepartment(em, d.getId());
+        assertNoneSQLAnyOrder("SELECT .* DC_DEP_CERT .*");
+        resetSQL();
+        certs = d.getCertifications();
+        assertNoneSQLAnyOrder("SELECT .* DC_DEP_CERT .*");
+        assertTrue(certs instanceof DelayedProxy);
+        assertEquals(2,certs.size());
+        assertAnySQLAnyOrder("SELECT .* DC_DEP_CERT .*");
+        
+        em.close();
+    }
+
+    /*
+     * Verify that an eager collection of embeddables works as expected
+     * (no delay load) with delayed loading enabled
+     */
+    public void testEagerEmbeddableCollection() {
+        EntityManager em = emf.createEntityManager();
+        
+        IDepartment d = createDepartment();
+        
+        Collection<Award> awards = createAwards();
+        awards.add(createAward());
+        awards.add(createAward());
+        awards.add(createAward());
+        d.setAwards(awards);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        
+        resetSQL();
+
+        em.clear();
+        
+        d = findDepartment(em, d.getId());
+        assertAnySQLAnyOrder("SELECT .* DC_DEP_AWD .*");
+        resetSQL();
+        awards = d.getAwards();
+        ProxyCollection pxycoll = (ProxyCollection)awards;
+        assertFalse(pxycoll.getOwner().isDelayed(pxycoll.getOwnerField()));
+        assertNoneSQLAnyOrder("SELECT .* DC_DEP_AWD .*");
+        assertTrue(awards instanceof DelayedProxy);
+        assertEquals(3,awards.size());
+        assertNoneSQLAnyOrder("SELECT .* DC_DEP_AWD .*");
+        
+        em.close();
+    }
+
+
+    /*
+     * Verify that a collection can be loaded post detachment
+     */
+    public void testPostDetach() {
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and an employee
+        IDepartment d = createDepartment();
+        IEmployee e = createEmployee();
+        e.setDept(d);
+        e.setEmpName("John");
+        Collection<IEmployee> emps = createEmployees();
+        emps.add(e);
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        resetSQL();
+        em.clear();
+        
+        d = findDepartment(em, d.getId());
+        emps = d.getEmployees();
+        em.close();
+        
+        // assert there was no select on the employee table
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        assertTrue(emps instanceof DelayedProxy);
+        DelayedProxy dep = (DelayedProxy)emps;
+        dep.setDirectAccess(true);
+        assertEquals(0, emps.size());
+        dep.setDirectAccess(false);
+        assertNotNull(emps);
+        // call contains and assert a select from the employee table
+        // occurred that the expected entities are returned.
+        resetSQL();
+        assertTrue(emps.contains(e));
+        e = getEmployee(emps, 0);
+        assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        resetSQL();
+        assertEquals(1, emps.size());
+        // Verify the delay load entity is detached
+        assertTrue(e instanceof PersistenceCapable);
+        PersistenceCapable pc = (PersistenceCapable)e;
+        assertTrue(pc.pcGetStateManager() instanceof DetachedStateManager);
+        // verify a second SQL was not issued to get the size
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        
+        // add a employee to the collection and merge
+        IEmployee e2 = createEmployee();
+        e2.setDept(d);
+        emps.add(e2);
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.merge(d);
+        em.getTransaction().commit();
+        emps = d.getEmployees();
+        // assert the insert into the employee and join table
+        assertAnySQLAnyOrder("INSERT INTO DC_DEP_EMP .*");
+        assertAnySQLAnyOrder("INSERT INTO DC_EMPLOYEE .*");
+        assertEquals(2, emps.size());
+        em.close();
+
+        // remove an employee from the collection and merge
+        emps.remove(e);
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.merge(d);
+        em.getTransaction().commit();
+        emps = d.getEmployees();
+        
+        // assert the delete from the join table
+        assertAnySQLAnyOrder("DELETE FROM DC_DEP_EMP .*");
+        assertEquals(1, emps.size());
+        em.close();
+    }
+    
+    /*
+     * Verify that a lazy collection within an embeddable can be
+     * delayed.  The to-many in the embeddable uses 
+     */
+    public void testEmbeddableRelationship() {
+        EntityManager em = emf.createEntityManager();
+        
+        IUserIdentity ui = createUserIdentity();
+        IMember m = createMember("Member 1");
+        ui.setMember(m);
+        
+        Collection<IAccount> accounts = createAccounts();
+        IAccount checking = createAccount("Checking", ui);
+        accounts.add(checking);
+        IAccount savings = createAccount("Savings", ui);
+        accounts.add(savings);
+        
+        em.getTransaction().begin();
+        em.persist(ui);
+        em.persist(checking);
+        em.persist(savings);
+        em.getTransaction().commit();
+        
+        em.clear();
+        
+        ui = findUserIdentity(em, ui.getId());
+        
+        m = ui.getMember();
+        resetSQL();
+        accounts = m.getAccounts();
+        
+        ProxyCollection pxycoll = (ProxyCollection)accounts;
+        assertTrue(pxycoll.getOwner().isDelayed(pxycoll.getOwnerField()));
+        assertNoneSQLAnyOrder("SELECT .* DC_ACCOUNT .*");
+        assertTrue(accounts instanceof DelayedProxy);
+        // Trigger a load via iterator
+        int count = 0;
+        for (IAccount a : accounts) {
+            count++;
+        }
+        assertEquals(2,count);
+        assertAnySQLAnyOrder("SELECT .* DC_ACCOUNT .*");
+        
+        em.close();
+    }
+
+    /**
+     * Verifies proxy methods which require loading the collection will trigger a
+     * load.
+     */
+    public void testProxyMethods() {
+        // Load up a collection
+        EntityManager em = emf.createEntityManager();
+        
+        // Create a new department and employees
+        IDepartment d = createDepartment();
+        Collection<IEmployee> emps = createEmployees();
+        for (int i = 0; i < 50; i++) {
+            IEmployee e = createEmployee();
+            e.setDept(d);
+            e.setEmpName("Employee: " + i);
+            emps.add(e);
+        }
+        d.setEmployees(emps);
+        
+        em.getTransaction().begin();
+        em.persist(d);
+        em.getTransaction().commit();
+        em.clear();
+        
+        resetSQL();
+        
+        // build a list of public proxy methods
+        // exclude those methods that are certain not to cause a load
+        // add(Object) remove(Object), addAll(Collection), removeAll(Collection), poll?, copy()
+        Class<?> collType = emps.getClass();
+        Method[] methods = collType.getMethods();
+        for (Method m : methods) {
+            if (!excludeMethod(m)) {
+                buildAndInvoke(m, em, d.getId(), emps);
+            }
+        }
+        em.close();
+    }
+
+    private void buildAndInvoke(Method m, EntityManager em, int id, Collection<IEmployee> emps) {
+        em.clear();
+        resetSQL();
+        IDepartment d = findDepartment(em, id);
+        Collection<?> emps2 = d.getEmployees();
+        assertTrue(emps2 instanceof DelayedProxy);
+        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        try {
+            m.invoke(emps2, buildArgs(m, emps));
+            // not checking result or exception, just whether load was triggered
+        } catch (Throwable t) {
+            // gulp
+        }
+        if (_delayMethods.contains(stringMethodName(m))) {
+            assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        } else {
+            assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+        }
+    }
+
+    /**
+     * Build up a set of generic args just to get the basic calls through.
+     */
+    private Object[] buildArgs(Method m, Collection<?> emps) {
+        Class<?>[] parmTypes = m.getParameterTypes();
+        if (parmTypes == null) {
+            return new Object[]{};
+        }
+        int intNum = 0;
+        int objNum = 0;
+        Object[] parms = new Object[parmTypes.length];
+        for (int i = 0; i < parmTypes.length; i++) {
+            Class<?> parmType = parmTypes[i];
+            if (parmTypes[i].equals(int.class)) {
+                parms[i] = intNum;
+                intNum++;
+                continue;
+            }
+            if (parmTypes[i].equals(boolean.class)) {
+                parms[i] = true;
+                continue;
+            }
+            if (parmTypes[i].equals(Object.class)) {
+                parms[i] = emps.toArray()[objNum];
+                objNum++;
+                continue;
+            }
+            if (parmTypes[i].isAssignableFrom(Collection.class)) {
+                parms[i] = emps;
+                continue;
+            }
+        }
+        return parms;
+    }
+
+    /*
+     * Determines whether a proxy method should be invoked
+     */
+    private boolean excludeMethod(Method m) {
+        if(_ignoreInterfaces.contains(m.getDeclaringClass())) {
+            return true;
+        }
+        if (_ignoreMethods.contains(stringMethodName(m))) {
+            return true;
+        }
+        return false;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/DelayedProxyCollectionsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IAccount.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IAccount.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IAccount.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IAccount.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+public interface IAccount {
+    
+    public void setId(int id);
+
+    public int getId();
+
+    public void setName(String name);
+
+    public String getName();
+
+    public void setUserIdent(IUserIdentity userIdent);
+
+    public IUserIdentity getUserIdent();
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IAccount.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IDepartment.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IDepartment.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IDepartment.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IDepartment.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+public interface IDepartment { 
+
+    public void setEmployees(Collection<IEmployee> employees);
+
+    public Collection<IEmployee> getEmployees();
+    
+    public void setId(int id);
+
+    public int getId();
+
+    public void setLocations(Collection<Location> locations);
+
+    public Collection<Location> getLocations();
+
+    public void setProducts(Collection<Product> products);
+
+    public Collection<Product> getProducts();
+
+    public void setCertifications(Collection<Certification> certifications);
+
+    public Collection<Certification> getCertifications();
+
+    public void setAwards(Collection<Award> awards);
+
+    public Collection<Award> getAwards();
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IDepartment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IEmployee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IEmployee.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IEmployee.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IEmployee.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+public interface IEmployee {
+
+    public void setEmpName(String empName);
+
+    public String getEmpName();
+
+    public void setId(int id);
+
+    public int getId();
+
+    public void setDept(IDepartment dept);
+
+    public IDepartment getDept();
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IEmployee.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IMember.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IMember.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IMember.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IMember.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.util.Collection;
+
+public interface IMember {
+
+    public void setName(String name);
+
+    public String getName();
+
+    public void setAccounts(Collection<IAccount> accounts);
+
+    public Collection<IAccount> getAccounts();
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IMember.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IUserIdentity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IUserIdentity.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IUserIdentity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IUserIdentity.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+public interface IUserIdentity {
+
+    public void setMember(IMember member);
+
+    public IMember getMember();
+
+    public void setId(int id);
+
+    public int getId();
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/IUserIdentity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Location.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Location.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Location.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Location.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.proxy.delayed;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Entity
+@Table(name="DC_LOCATION")
+public class Location implements Serializable, Comparable<Location> {
+
+    private static final long serialVersionUID = -8396529344135184546L;
+
+    @Id
+    @GeneratedValue
+    @Column(name="LOC_ID")
+    private int id;
+
+    private String address;
+    
+    private String city;
+    
+    private String zip;
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setZip(String zip) {
+        this.zip = zip;
+    }
+
+    public String getZip() {
+        return zip;
+    }
+    
+    @Override
+    public int compareTo(Location l) {
+        return new Integer(getId()).compareTo(l.getId());
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/Location.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message