• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Doubt...

 
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 pool...in your ejbLoad() ..use the context to get your primary key...load this bean using this primary key..now 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 data..no 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 Transaction..one 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 unavailable..it will call ejbActivate()..now 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 explanation..read the top part again

Happy Hunting
[ April 07, 2006: Message edited by: Rahul Mishra ]
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic