You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Bruno René Santos <br...@holos.pt> on 2012/02/22 11:54:08 UTC

Bug delete rules - Cascade & Deny

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

Re: Bug delete rules - Cascade & Deny

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 22/02/12 9:54 PM, Bruno René Santos wrote:


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

3.1M3 was released late last year.

   http://cayenne.apache.org/2011/09/26/cayenne-31m3-is-released.html

There are a number of people running that successfully in production.



Ari



-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A