Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic