wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes EJB how to? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB how to?" Watch "EJB how to?" New topic
Author

EJB how to?

Richard Wilson
Ranch Hand

Joined: Jan 12, 2002
Posts: 57
Can you tell me how session beans call entity beans to make transactions?
I use WebLogic 6.1 plus JBuilder7.0.
Thanx in advance!


Richard Wilson
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Can you tell me how session beans call entity beans to make transactions?

Do you mean "transactions" as in "I want to rollback if something goes wrong" or as in "I am doing some operation that the regular folks call a transaction"? I am assuming the latter...
1) Get an InitialContext. If the beans are in the same application, a simple new InitialContext() should do (otherwise you'll need to give some configuration parameters to the constructor).
2) Make a JNDI lookup for the entity bean's home interface. This could be done either by using the full JNDI name (e.g. "ejb/com/mycompany/ejbs/MyEntityBean"), or a logical JNDI name (e.g. "java:comp/env/ejb/MyEntityBean"). This depends on your ejb-jar.xml.
3) Use the home interface for creating/finding the entity you want
4) Invoke methods on the entity bean.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: EJB how to?
 
Similar Threads
Refactoring
How to Creating the JavaBeans using MySql
Invoking new() on a bean class?
How beans in EJB3.0 are threadsafe?
EJB slow first time-WAS 5.0