Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

futher ToManyList & PersistentObjectList refactring

git-svn-id: https://svn.eu.apache.org/repos/asf/cayenne/main/trunk@765237 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit f5f3ce453155e2f6c09c68c41ff851f4e06eca93 1 parent bbb97d2
andrey authored
View
22 framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java
@@ -73,34 +73,18 @@ public int hashCode() {
// Tracking list modifications, and resolving it
// on demand
// ====================================================
-
+
@Override
- protected boolean removeLocal(Object object) {
- if (addedToUnresolved != null) {
- addedToUnresolved.remove(object);
- }
-
- if (removedFromUnresolved == null) {
- removedFromUnresolved = new LinkedList<Object>();
- }
-
+ protected boolean shouldAddToRemovedFromUnresolvedList(Object object) {
// No point in adding a new or transient object -- these will never be fetched
// from the database.
- boolean shouldAddToRemovedFromUnresolvedList = true;
if (object instanceof Persistent) {
Persistent dataObject = (Persistent) object;
if ((dataObject.getPersistenceState() == PersistenceState.TRANSIENT)
|| (dataObject.getPersistenceState() == PersistenceState.NEW)) {
- shouldAddToRemovedFromUnresolvedList = false;
+ return false;
}
}
-
- if (shouldAddToRemovedFromUnresolvedList) {
- removedFromUnresolved.addLast(object);
- }
-
- // this is really meaningless, since we don't know
- // if an object was present in the list
return true;
}
View
11 framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java
@@ -375,12 +375,21 @@ protected boolean removeLocal(Object object) {
removedFromUnresolved = new LinkedList<Object>();
}
- removedFromUnresolved.addLast(object);
+ if (shouldAddToRemovedFromUnresolvedList(object)) {
+ removedFromUnresolved.addLast(object);
+ }
// this is really meaningless, since we don't know
// if an object was present in the list
return true;
}
+
+ /**
+ * @return whether object should be added to {@link #removedFromUnresolved} during removal
+ */
+ protected boolean shouldAddToRemovedFromUnresolvedList(Object object) {
+ return true;
+ }
protected void postprocessAdd(Collection collection) {
Iterator it = collection.iterator();
Please sign in to comment.
Something went wrong with that request. Please try again.