This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar


Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • 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
  • 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 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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!