You don't have to do anything if you set up your transaction attributes
correctly.

If all this creating takes place in the context of one transaction which is
demarcated within a method of your session bean, a transaction failure of anyone
of the creates can be thrown outside the scope of the session bean to cause all
the creates to automatically role back. That's the point of EJB, to aggregate
transactional components into larger units of work.

SessionBean (manages work flow)
someMethod( )
{
        create CMP 1
        create CMP 2
        ...
        create BMP 1
}

Throwing a transaction or run-time exception out side the scope of the Session
bean will cause all work that occurred in scope of the transaction to be rolled
back.  The CMP and BMP entity beans should propagate the transaction of the
Session bean.

Chaganthi, Madhusudan R. wrote:

> Hi All,
>
> I have a question regarding controlling transactions specific to a session
> bean doing business on behalf of numerous entity beans.
>
> My session bean talks to 9 different CMP entity beans (9 different tables)
> and 1 BMP bean (2 different tables) to create one complete object (an
> Inventory Iem in our case). The BMP bean can be created only after ALL the 9
> cmp beans have been successfully created.
>
> How can I control the transaction in my session bean so that I can roll back
> in case a failure occurs in any point of time during this numerous create()
> calls ?
>
> I was thinking about storing the primary keys of each cmp bean after it is
> created and if at all a bean rolls back, I can go back and remove the prior
> ones with a findByPrimaryKey followed by remove method. I wasnt too sure
> about encapsulating all the create methods in one big transaction since that
> might lead to nested transaction scenarios. Am I right?
>
> Any pointers would be helpful.
>
> Regards
>
> Madhu
>
> Madhusudan R Chaganthi
> > Centers for Disease Control and Prevention
> > NCID/SRP/IRM (404) 639-2462
> [EMAIL PROTECTED]
>
> In three words I can sum up everything I've learned about life:
> It Goes On.
>
> ===========================================================================
> 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".



--
Richard Monson-Haefel
Author of Enterprise JavaBeans
Published by O'Reilly & Associates

===========================================================================
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