> -----Original Message-----
> From: Ram Ji [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 02, 2000 11:47 PM
> To: [EMAIL PROTECTED]
> Subject: rollback in ejbRemove()
>
>
> can i call setRollbackOnly() in ejbRemove of a bean-managed
> Entity Bean.?
> i have declared the txn attribute as Required in the xml-DD
> for the remote
> interface methods as well as Home-intf methods. but my
> container complains
> that IllegalStateException, bean method not participating in a txn....
>
> how do i check whether my bean is participating in a txn or
> not, thou i have
> declared Required as my txn attribute.
>
>
>
> actually, i have an entity bean, that has an object, which is
> a root of a
> tree
> of objects. so whenever ejbremove is called on my entity
> bean, i would call
> the delete method on root of the tree, which in turn
> traverses the tree and
> deletes each and every node.
> if any of the nodes failes to delete itself, then i throw an
> user defined
> exception. upon catching the exception the ejbRemove has to
> rollback so that
> all deleted nodes are brought back. any suggestions?
>

You can do something like this:

public class MyTreeNode implements EntityBean {

  public void ejbRemove() throws RemoteException, RemoveException {
    try {
      Collection col = this.getChildren();
      Iterator it = col.iterator();
      while (it.hasNext()) {
        ((MyTreeNode) javax.rmi.PortableRemoteObject.narrow(it.next(),
MyTreeNode.class)).remove();
      }
    } catch(Exception ex) {
      throw new EJBException(ex);
    }
  }
}

the ejbRemove catches exceptions from his children, wraps it in an
EJBException and throws it further. The EJBException automatically leads to
a rollback.


Mit freundlichen Gr��en
With kind regards

Ulf Gohde
System Architect
CE Computer Equipment AG     Fon: +49 (0)521 9318-167
Herforder Str. 155a          Fax: +49 (0)521 9318-444
33609 Bielefeld              E-Mail:[EMAIL PROTECTED]
Germany                      http://www.ce-ag.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to