cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno René Santos <brunor...@holos.pt>
Subject Bug delete rules - Cascade & Deny
Date Wed, 22 Feb 2012 10:54:08 GMT
Hello all,

On version 3.0.1 i have just found out a problematic behaviour. If on the
modeler we have a DB structure like this (with delete rules included):

A -> bArray (Cascade) -> B -> cArray (Deny)

The first time we try to delete A the DeleteDenyException happens but the
second time it doesn't because on the DataContextDeleteAction.java on
the deletePersistent method the following code is executed:

object.setPersistenceState(PersistenceState.DELETED);
dataContext.getObjectStore().nodeRemoved(object.getObjectId());
processDeleteRules(object, oldState);

which will mark an Object as deleted BEFORE testing all the object tree for
Deny rules... this will fail (no exception thrown) on the second time
because object A is already marked as DELETED, preventing a second test on
the tree. I tried doing this

processDeleteRules(object, oldState);
object.setPersistenceState(PersistenceState.DELETED);
dataContext.getObjectStore().nodeRemoved(object.getObjectId());

but as the class is protected to run inside the package
org.apache.cayenne.access I was having a lot of work to extract it from the
package and even then the exception was correctly raised but when I tried
doing anything else on that context session I would also get a
DeleteDenyException on places I wasn't expecting.

My solution was to create a method canDelete on the CayenneDataOject that
tests the current object for deletion using the same algorithm from
deletePersistent but without the setters and modeRemoved method. Only the
DeleteDenyExpection is thrown. I run this before the deleteObject method
and so if I get to it is because I can safely delete the current object.

I dont know if this issue was address on recent builds...

By the way any schedule on releasing at least a beta version of cayenne 3.1?

Regards
Bruno Santos

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message