File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Loading and Caching Entity Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Loading and Caching Entity Beans" Watch "Loading and Caching Entity Beans" New topic

Loading and Caching Entity Beans

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 556
Lets say at server startup I want to load an entire table say customer into memory.
Each entity bean maps to a row, how would I load each row into each entity bean in one call. So far all I have seen are examples of a session bean calling one entity bean.
Lets say I want to load a 100 customers, would I use one session bean with a loop calling each entity bean in turn. In all the examples I have seen the connection is created in the Entity bean, but if I use that method here then in my loop I would be opening and closing a connection 100 times.
The way I see it I would open the connection, then pass the connection to each entity bean home interface.
Is there another neater way, is there a way to configure a server like weblogic to set up this Entity Bean cache for me.
Thanks for any help Tony
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Yes, it's called "Option A EJB Caching" and it's supported by all EJB servers. (Read the EJB spec for more information...) Do a search of the WebLogic documentation (or a google search) for "Option A" and you'll find out how to set it.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Also -- are you only looking at BMP examples? Have you considered CMP?
I agree. Here's the link:
subject: Loading and Caching Entity Beans
Similar Threads
ejbFindByPrimary method has a flaw ..... I think
How do you map a table to a collection of Entity Beans
Using Weblogic to cache data at startup
few doubts in MVC design pattern and EJB Concepts
Always wrap Entity beans in Session beans?