Hi virgil,
In all the entity beans, add the following line in your catch
block
like
public class myEntityBean implements EntityBean
{
protected EntityContext ctx;
myMethod()
{
try
{
... //Your code goes here...
}
catch (SomeException e)
{
ctx.setRollbackOnly(); // To set the
transaction to roll back
}
}
public void setEntityContext(EntityContext ctx) throws
RemoteException
{
this.ctx=ctx;
}
public void unSetEntityContext() throws RemoteException
{
this.ctx=null;
}
}
The above sets the transaction to be rolled back. Hence the when
the transaction completes and the container looks back to see whether,
to roll back or commit the transaction, it checks this flag, and hence
rolls back the transaction
Hope this helps..
Cheers!
-Suresh
************************************************************************
*****************************************************
Ponnalagar Krishnan
Senior Associate,
MindTree Consulting Limited,
Banagalore
mail - [EMAIL PROTECTED]
fone - 6545263/64/65/66 xtn - 213
"If everything is coming your way, then you are in the wrong lane"
************************************************************************
*****************************************************
> -----Original Message-----
> From: Virgil Lee [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 01, 2000 7:17 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Transaction Problem
>
>
> Hi,
>
> I have a session bean function that calling three entity
> beans as a unit of
> work.
> The function simply calls the entity beans' create function
> one by one.
> Suppose when calling the third one it throws an exception,
> that case the
> whole transaction should be rolled back.
> I got the remote exception from the client calling the session bean
> function:
> Transaction was rolled back: javax.ejb.EJBException; nested
> exception is:
> javax.ejb.EJBException
>
> which is normal I suppose. But the fact is when I check back
> the database,
> nothing was rolled back, the newly inserted records for the
> first two entity
> beans are there.
>
> The transaction type is container and I've set the session bean's
> trans-attribute as Required and others as Supports.
> I'm using BMP, and every call to the database I need to make
> a connection
> and close it afterward. It seems to me that when the
> connection has been
> closed, it commits everything and the container cannot roll
> anything back.
>
> I'm struggling on this for a period of time already, any
> clues or help are
> much appreciated.
>
> Thanks and Regards
> Virgil
>
> ==============================================================
> =============
> 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".
>
>
===========================================================================
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".