In other projects we have cached data from the database
in read-only singletons. I am not sure how to do this in EJB. I figure that we can create Entity beans that have a <cache-strategy> set to Read-Only and persistence <db_is_shared> set to false. This should enable a CMP entity bean to be cached, but how de we get all
the rows loaded efficiently at startup without having to hit the database once for every row? Does anyone have the answer?
-
caching data with entity beans (11 messages)
- Posted by: James Goldstein
- Posted on: March 12 2001 17:09 EST
Threaded Messages (11)
- caching data with entity beans by Nayan Gupta on March 13 2001 03:46 EST
- caching data with entity beans by James Goldstein on March 13 2001 10:33 EST
-
caching data with entity beans by qing yan on March 14 2001 02:03 EST
-
caching data with entity beans by Stanislav Markin on March 14 2001 06:18 EST
-
caching data with entity beans by qing yan on March 14 2001 01:57 EST
-
caching data with entity beans by qing yan on March 14 2001 02:04 EST
- caching data with entity beans by James Goldstein on March 14 2001 02:18 EST
-
caching data with entity beans by James Goldstein on March 14 2001 02:35 EST
- caching data with entity beans by qing yan on March 14 2001 06:35 EST
-
caching data with entity beans by qing yan on March 14 2001 02:04 EST
- caching data with entity beans by James Goldstein on March 14 2001 02:05 EST
-
caching data with entity beans by qing yan on March 14 2001 01:57 EST
- caching data with entity beans by James Goldstein on March 14 2001 01:45 EST
-
caching data with entity beans by Stanislav Markin on March 14 2001 06:18 EST
-
caching data with entity beans by qing yan on March 14 2001 02:03 EST
- caching data with entity beans by James Goldstein on March 13 2001 10:33 EST
-
caching data with entity beans[ Go to top ]
- Posted by: Nayan Gupta
- Posted on: March 13 2001 03:46 EST
- in response to James Goldstein
With the help of Connection Pooling u can have a connection and can use that only for this purpose ,means to say simply have a con object and make it persistent and without returning that con u can have the states of ur Entity Bean object.
Rajeev -
caching data with entity beans[ Go to top ]
- Posted by: James Goldstein
- Posted on: March 13 2001 10:33 EST
- in response to Nayan Gupta
I am sorry, but I do not understand your solution. -
caching data with entity beans[ Go to top ]
- Posted by: qing yan
- Posted on: March 14 2001 02:03 EST
- in response to James Goldstein
There is no value using entity bean for this, use stateless session instead. -
caching data with entity beans[ Go to top ]
- Posted by: Stanislav Markin
- Posted on: March 14 2001 06:18 EST
- in response to qing yan
Where will you cache data in stateless beans? Only in static fields as I think...
As for the read-only beans, this is the feature of WebLogic server (only?). So to fill the cache at startup you may use weblogic-specific Startup-classes (method of startup class is called by weblogic during server startup process). -
caching data with entity beans[ Go to top ]
- Posted by: qing yan
- Posted on: March 14 2001 13:57 EST
- in response to Stanislav Markin
Not necessary, you can initialize the object fields in the ejbcreate() or setEntityContext() and never worry about
passivation/activation issues, stateless SB means no client
specific state, not means no state itself. -
caching data with entity beans[ Go to top ]
- Posted by: qing yan
- Posted on: March 14 2001 14:04 EST
- in response to qing yan
Use entity bean if you have some share data that need to
be accessed(read and write) concurrently and you want
to ensure the ACID properties. -
caching data with entity beans[ Go to top ]
- Posted by: James Goldstein
- Posted on: March 14 2001 14:18 EST
- in response to qing yan
This makes sense. Thanks. -
caching data with entity beans[ Go to top ]
- Posted by: James Goldstein
- Posted on: March 14 2001 14:35 EST
- in response to qing yan
Wouldn't this mean that every instance in the pool
would have to hit the database and what about refreshing the data periodically. -
caching data with entity beans[ Go to top ]
- Posted by: qing yan
- Posted on: March 14 2001 18:35 EST
- in response to James Goldstein
I am afraid so, you don't want a singleton stateless
session bean, do you:-)
About refreshing, it depend on your requirements,
one way to do this is create a timer manually:
reload()
{
...//read data from backend
last_refresh_time=currenttime();
}
foo()
{
if (currenttime()-last_refresh_time>REFRESH_INTERVAL)
reload();
....//serving client here
}
-
caching data with entity beans[ Go to top ]
- Posted by: James Goldstein
- Posted on: March 14 2001 14:05 EST
- in response to Stanislav Markin
Even with a startup class, won't the ejbLoad() be called for every row making it much less efficient than a
single select statement? -
caching data with entity beans[ Go to top ]
- Posted by: James Goldstein
- Posted on: March 14 2001 13:45 EST
- in response to qing yan
I currently have it in a stateless bean. I ultimately
wanted to put more data access in entity beans to stick
with a common approach. At this point this seems unlikely.
Every time I want to move to Entity Beans there are reasons why we shouldn't and ambiguous information regarding them. Do you know under what conditions the use of entity beans is definitely a good idea?