File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt..." Watch "Doubt..." New topic


agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
Whats the meaning of following tips from Giju George's notes--
1).Container needs to call ejbActivate(), ejbLoad() before it can call a ejbRemove().

2).ejbLoad(), ejbRemove(), ejbSelect() --> runs in the tx context of the method that causes it's invocation.
Rahul Mishra
Ranch Hand

Joined: Jan 22, 2006
Posts: 211
Although i havent read those notes but Here is the deal ..

When you call ejbRemove()? do you have any idea what to remove? As in which Entity?

So, Here is what you do?

Activate a bean instance from the your ejbLoad() ..use the context to get your primary key...load this bean using this primary you are all set to remove..arent you?

The implementation may differ..but logic remains the same

To your next Question...
Try thinking on these lines..

1) When would i usually need a Transaction?
Answer) Normally when i use a business method for reading data from the database?

2) Why then?
Answer) Because with a proper locking level during the Transaction..i would ensure that when my EJB operates on the one else can..

Now, back to your Question

Typically you would call an ejbSelect()..through a home business method or to select data straight from the bean(not exposed to client). For this you should do it in Transaction...

Unlike others ejbRemove() of an entity bean runs in a of the reasons being..that you dont want any other access to the data while you are removing it

Now, coming to the fact that why do they the context of Transaction that invoked them...

When you invoke a business method on an EJB Object...and the particular entity bean instanceis will call ejbActivate() thats too early for a transaction..then container calls ejbLoad()..where you load database data...apt place to begin transaction and lock database row(may be)..Rest the top part again

Happy Hunting
[ April 07, 2006: Message edited by: Rahul Mishra ]

My SCEA experience:
I agree. Here's the link:
subject: Doubt...
It's not a secret anymore!