• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbLoad() question...

 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to load some data from the database on application server start up and cache that data.
Is it ok to put the database access code in the ejbLoad() method of a BMP??
Can the container call the ejbLoad() method multiple times resulting in unwanted database calls and refreshing the data in cache which is not required??
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ejbLoad() will be called (in most cases) once per transaction for each EJB instance.

I would suggest you take a look at Richard Monson-Haefel's book on EJB's, which covers this in detail, as well as examining the interaction diagrams in the spec, which also answer this question in detail and give the conditions under which ejbLoad() is called.

Kyle
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Jain:
Is it ok to put the database access code in the ejbLoad() method of a BMP??

Yes, that is what it is there for.

Originally posted by Gaurav Jain:
Can the container call the ejbLoad() method multiple times resulting in unwanted database calls and refreshing the data in cache which is not required??

See this thread for a relevant discussion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!