Here is how i would do it:
The method in your session bean has tx attribute TX_REQUIRED and the create
method in all your entiy beans has tx attribute TX_MANDATORY. This way a tx will
be started when the method in session bean is started and will be commited if
all the entity beans has been correctly created, otherwise every work is rolled
back. No more coding of yourself, the container will manage it (at least the one
i'm using :-)
/Lennart
"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".
--
________________________________
Lennart Petersson
Benefit AB
Bergendorffsgatan 5A
S-652 24 Karlstad
Phone: +46 (0)54 177253
mailto:[EMAIL PROTECTED]
Yahoo! Messenger, my nickname is: bit_av_en_kaka
http://www.benefit.se
===========================================================================
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".