> -----Original Message-----
> From: Ram Ji [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 02, 2000 8:30 PM
> To: [EMAIL PROTECTED]
> Subject: rollback a txn
>
>
> I have doubt in whether can I call setRollbackOnly() from
> ejbRemove() method
> of an Entity Bean.
>
> Actually my entity bean has an object, which is the root of a
> tree of objects.
> so whenever my entity bean is removed, i will invoke the
> delete function on
> the tree's root. if any of the node in the tree fails during
> the deleting from
> the database, i throw an exception. my entity bean upon
> catching the exception
> should roll back the whole txn, so that partial deletion of
> tthe nodes in the
> tree are undone.
> any suggestions on this ?
>
> tia
> Ramji
>
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".