• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbStore and ejbLoad methods...  RSS feed

 
Chuck Meduri
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have written a bean managed persistence bean and have a business method which returns the number of records for a particular user in the form of an enumeration of records. I use JDBC to access the database. Everything is working correctly. When I hop through the enumeration getting each element in the enumeration and call the getter on the businessObject, I also get the right information which is then displayed in a table. Since it was taking a long time to get even few records, I put some system outs in my ejbStore and ejbLoad methods and have the usual jdbc stuff in these methods to update and do a select from the database, to find out where the bottleneck was.
My question is -- every time I call the getter methods on the businessObjects while printing out the information from each businessObject during my hoping in the enumeration, my log files show that the ejbStore method and the ejbLoad method is called every single time I go through the while loop until there are no more elements in the enumeration. Isn't this a heavy strain on the database and the connectivity to basically obtain a connection and do a update each time? Or is there something I am missing here? My log files are growing enormously big even when the number of records returned is pretty small say 10 or 15 records.
Could somebody help me explain as to why the ejbstore and the ejbLoad method are getting called each time the while loop is entered when trying to display the data.
Thanks you in advance,
Chuck
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container may be taking a conservative approach to your data. By calling ejbStore each time you release the EJB, it's pushing any changes out to the DBMS and by calling ejbLoad, it's making sure that the data is in fact the most recently available in the DBMS.
One thing you can do to reduce overhead is to track changes to the data with a "dirty-data" flag and in the ejbStore method bypass the write operation if there are no changes.
Other things you can do are to use a connection pool to reduce the overhead of establishing a DBMS connection and check your EJB server options to see if you can make it do less pessimistic calls to load/store.
For large enumerations, however, you may just be seeing the caching mechanism at work. Rather than keep a distinct EJB for each and every result row, the system may be using a more limited number of EJBs and loading them on demand in the same way that virtual memory does for RAM pages.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!