Hi Hugi

So crazy idea number one is to maybe duplicate your model and revise the delete rules, then use this DeleteModel to nuke the customer. The downside of this is having to maintain two models, maybe not such a good idea ?

Idea number two is to add a delete method to each of the classes that first deletes the children. So you have:

Customer ->> Invoice ->> InvoiceLine ->> InvoiceLineSums

Then add deleteLineSums() to InvoiceLine that deletes its InvoiceLineSums with something like: getObjectContext().deleteObjects( getLineSums() );

Do the same in Invoice where deleteLines() is something like:

   for ( InvoiceLine line : getLines() )  line.deleteLineSums();
   getObjectContext().commitChanges();
   getObjectContext().invalidateObjects( this );
   getObjectContext().deleteObjects( getLines() );

Then the same for Customer .... The downside of all this is that it's not very efficient in terms of DB calls, but then you won't have to go all caveman like and "write out damn joins like our ancestors did" :-)

Cheers
Jurgen

Reply via email to