You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mid491 mid491 <mi...@hotmail.com> on 2010/04/07 17:26:19 UTC

cascade delete into transactionBean.call


I got two classes : parent (oneToMany) (1) ---> (0-*) child (manyToOne)
the "Parent" relationship is annoted cascadeType.REMOVE and LAZY mode and it's a collection.the "Child" is EAGER
I use the openEJB tip to have my tests under a transaction (http://openejb.apache.org/3.0/unit-testing-transactions.html) because my methods to test required a transaction.
My problem is with the cascadeType.REMOVE : if I delete the Parent into the transactionBean.call() the child are not deleted (I see only a SQL delete on Parent), but if I put the delete outside the transactionBean.call() all works fine !! (same into a @after test) :
@Testpublic void createParent() throws Exception {    Caller transactionBean = (Caller) getInitialContext().lookup("TransactionBeanLocal");   transactionBean.call   (      new Callable<Object>()       {         public Object call() throws Exception          {            // here the testing code            create a parent, create a child, attach child to parent            delete parent ===> cascade don't work !            return null;         }      }   );   delete parent ===> work fine the relation ship is empty!}

I guess the cascade is not working because I am into the openEJB transcation, but I don't realy understand why ? 
thanks ! 		 	   		  
_________________________________________________________________
Consultez vos emails Orange, Gmail, Yahoo!, Free ... directement depuis HOTMAIL !
http://www.windowslive.fr/hotmail/agregation/