On 7/26/06, Mike Kienenberger <mkienen..mail.com> wrote:
> And with the changes to ToManyList, I've now been able to see that
> removedFromUnresolved contains a reference to my deleted object.
I'm now thinking that the solution to this problem is to not add NEW
or TRANSIENT objects to the removedFromUnresolved list. These
objects will never be removed from a database fetch list as they don't
exist in the database, so there's no point in keeping a reference to
them.
boolean removeLocal(Object object) {
if (addedToUnresolved != null) {
addedToUnresolved.remove(object);
}
if (removedFromUnresolved == null) {
removedFromUnresolved = new LinkedList();
}
// No point in adding a new or transient object -- these will
never be fetched from the database.
boolean shouldAddToRemovedFromUnresolvedList = true;
if (object instanceof DataObject) {
DataObject dataObject = (DataObject) object;
if ( (dataObject.getPersistenceState() ==
PersistenceState.TRANSIENT)
|| (dataObject.getPersistenceState() == PersistenceState.NEW) ) {
shouldAddToRemovedFromUnresolvedList = 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;
}
This archive was generated by hypermail 2.0.0 : Thu Jul 27 2006 - 13:50:55 EDT