Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

EJB-> java ->new EJB. What will be Txn status in the new EJB and should ejb-ref?

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- If an EJB is calling a java class and that java class is a client to another EJB, Do i also have to add that EJB to my ejb-ref?

2- This first EJB starts a transaction, will the second EJB (called as in above scenario) run in a new transaction?

Thanks Appreciate ur help.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pervaiz gul:
1- If an EJB is calling a java class and that java class is a client to another EJB, Do i also have to add that EJB to my ejb-ref?

2- This first EJB starts a transaction, will the second EJB (called as in above scenario) run in a new transaction?

Thanks Appreciate ur help.



Yes you need to add the ejb-ref for the first ejb indicating a reference of the second ejb in the first ejb.

Whether the 2nd ejb runs in the same transaction depends on the transaction attribute you have set.Use Required so that if there is already a running transaction it will run init and otherwise it will run in a new transaction.
 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks that worked. another question.
If a "java bean client" is calling many session EJBs and every EJB method has Txn Attribute 'Required' than will all the EJBs run in the same Txn or new ones for everyone.
I mean, the ejb called on the first line will create a new Txn for itself and than returns to the client. next line call another EJB with Required txn attrib, would the new EJB run in the previous EJB's txn or create a new one (If so then at what point is the last txn committed).

thanks and regards
GUL
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Each call from the client will start a new transaction and will be committed before returning to the client.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bhagyashree Jayaram:


Yes you need to add the ejb-ref for the first ejb indicating a reference of the second ejb in the first ejb.



A clarification why it is so:

The EJB container make no difference between code that is "in the bean" and in other classes called by the bean. The "helper class code" could have been inlined in the bean class and the container would see no difference.

So, even if code is broken out of the bean-class to helper classes, the code is nevertheless "in the bean".

Dan
 
A wop bop a lu bop a womp bam boom! Tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic