Hi Marco,

I had the same problem a while ago and I sent an e-mail to
the developer list about the issue. Included my e-mail from
13-11-2003 (quite long, sorry for that). It uses code
references that may be oudated). In the end I had to stop
using transactions.

Regards,
Ronald Wildenberg.


------------------------------------------------------------
Hi,

While working with MMBase transactions (MMBase 1.6.3), I found
two bugs that make it impossible to remove related objects. I
post these on the list because I do not have access to the
BugTracker system. The first is a more severe version of closed
bug 216, the second is not yet in BugTracker. Sorry if this
mail is a bit long.

Bug 1:
It is impossible to remove related nodes inside a transaction
in some cases. Suppose:
   A -> B -> C -> D and
        B -> E.

A, B and C are of type org.mmbase.bridge.Node. Goal is to remove
B and C including their relations and not A, D and E inside a
transaction. Nodes D and E may be images that are used in other
relations. The following will not work:

   C.remove(true);
   B.remove(true);

Reason for this is that if C is removed with relations,
the relations from C are added to the transaction first
(BasicNode:575) and are then flagged for deletion
(BasicNode:576). If B is then removed with relations, an
attempt is made to add the relation from B to C again to
the transaction, which fails, bacause it's already present
(TransactionManager:81).

Bug 2:
To solve the problem above, as also suggested in bug 216, one
might attempt to first delete the relations AB, BC, CD and BE.
This will not work inside a transaction. Deleting the relations
works fine, but calling e.g. 'B.delete(false);' fails. In
BasicNode:505 the core is asked whether B has any relations.
It still has, because the relations are deleted inside a
transaction and not yet physically removed.


Regards,
Ronald Wildenberg
------------------------------------------------------------


> -----Oorspronkelijk bericht-----
> Van: Marco Ciancimino [mailto:[EMAIL PROTECTED]
> Verzonden: woensdag 7 april 2004 12:24
> Aan: [EMAIL PROTECTED]
> Onderwerp: related node deletion
> 
> 
> Hi,
> I have two related builders: resources and metadata. I have 
> some trouble 
> deleting the nodes.
> 
> If I try:
> 
> metadata.delete(true);
> resource.delete();
> 
> the following error occours:
> org.mmbase.bridge.BridgeException: This node (239) cannot be 
> deleted. It 
> still has relations attached to it.
> 
> If I try:
> 
> metadata.delete(true);
> resource.delete(true);
> 
> the following error occours:
> org.mmbase.bridge.BridgeException: node not added as it was 
> already in 
> the transaction
> 
> Am I missed something? What is the right way for deleting 
> related nodes?
> 
> Thanks in advance,
> Marco
> 
> 
> 

Reply via email to