You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2006/01/23 10:54:44 UTC
svn commit: r371508 - in
/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy:
CollectionProxyDefaultImpl.java SetProxyDefaultImpl.java
Author: tomdz
Date: Mon Jan 23 01:54:37 2006
New Revision: 371508
URL: http://svn.apache.org/viewcvs?rev=371508&view=rev
Log:
Fix for OJB-90
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/SetProxyDefaultImpl.java
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java?rev=371508&r1=371507&r2=371508&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java Mon Jan 23 01:54:37 2006
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.Set;
import org.apache.ojb.broker.ManageableCollection;
import org.apache.ojb.broker.OJBRuntimeException;
@@ -654,6 +655,46 @@
{
_listeners.remove(listener);
}
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof Collection)
+ {
+ Collection ownRealData = getData();
+
+ if (ownRealData == null)
+ {
+ return false;
+ }
+ else if (obj instanceof CollectionProxyDefaultImpl)
+ {
+ Collection otherRealData = ((CollectionProxyDefaultImpl)obj).getData();
+
+ return ownRealData.equals(otherRealData);
+ }
+ else
+ {
+ return ownRealData.equals(obj);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode()
+ {
+ Collection ownRealData = getData();
+
+ return (ownRealData == null ? super.hashCode() : ownRealData.hashCode());
}
}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/SetProxyDefaultImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/SetProxyDefaultImpl.java?rev=371508&r1=371507&r2=371508&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/SetProxyDefaultImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/proxy/SetProxyDefaultImpl.java Mon Jan 23 01:54:37 2006
@@ -1,6 +1,6 @@
package org.apache.ojb.broker.core.proxy;
-/* Copyright 2003-2005 The Apache Software Foundation
+/* Copyright 2003-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,43 +24,51 @@
import org.apache.ojb.broker.util.collections.ManageableHashSet;
/**
- * A placeHolder for a whole set to support deferred loading of
- * relationships. The complete relationship is loaded on request.
+ * A proxy for a set that supports deferred loading of the elements upon request.
+ * Note that calls to {@link #equals(Object)} and {@link #hashCode()} will
+ * materialize all elements.
*
* @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
* @version $Id$
*/
public class SetProxyDefaultImpl extends CollectionProxyDefaultImpl implements Set
{
-
/**
- * Constructor for SetProxy.
- * @param aKey
- * @param aQuery
+ * Creates a new proxy instance.
+ *
+ * @param pbKey The key for the broker that this proxy is associated to
+ * @param query The backing query for the set data
*/
- public SetProxyDefaultImpl(PBKey aKey, Query aQuery)
+ public SetProxyDefaultImpl(PBKey pbKey, Query query)
{
- this(aKey, ManageableHashSet.class, aQuery);
+ this(pbKey, ManageableHashSet.class, query);
}
/**
- * Constructor for SetProxy.
- * @param aKey
- * @param aCollClass
- * @param aQuery
+ * Creates a new proxy instance.
+ *
+ * @param pbKey The key for the broker that this proxy is associated to
+ * @param collectionClass The type of the real set
+ * @param query The backing query for the set data
*/
- public SetProxyDefaultImpl(PBKey aKey, Class aCollClass, Query aQuery)
+ public SetProxyDefaultImpl(PBKey pbKey, Class collectionClass, Query query)
{
- super(aKey, aCollClass, aQuery);
+ super(pbKey, collectionClass, query);
}
+ /**
+ * Returns the real set data. If the data is not yet loaded, it will be fetched
+ * from the database.
+ *
+ * @return The real set data
+ */
protected Set getSetData()
{
return (Set)super.getData();
}
/**
- * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
+ * {@inheritDoc}
*/
protected Collection loadData() throws PersistenceBrokerException
{
@@ -74,7 +82,5 @@
{
throw new PersistenceBrokerException("loaded data does not implement java.util.Set");
}
-
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org