Hi! I have designed and implemented an administrative tool for handling generic orders, but it is performing poorly so I'm looking for suggestions. I'm using BMP (and don't want to use CMP). I have an order entity bean (called OrderBean) that I use to hold a list of lists of orders (new orders are in one list, shipped orders in another list, canceled orders in a third). Each order is an object, but this order entity bean is used to hold in memory all orders at once. When the OrderBean is loading up, it does one query to the database for all orders of a given status (eg, new orders) and then loops thru the ResultSet of orders and for each order, makes a call to another entity bean (called CustomerBean) from which it gets the customer info associated with that order. The CustomerBean works the same way as the OrderBean.... it loads up all customers on its ejbLoad instead of just a single customer. Granted that uses lots of memory, but that's not a problem for the system, and the advantage (ideally) is that after the first load, all customers are cached and I don't have to hit the database again at all. IF, later on, a customer id comes up that is not in the CustomerBean's cached hashtable of customers, I redo the entire database load (effectively refreshing the cache) to get the new customer(s). So maybe there are lots of problems with this design. Or maybe it's fairly standard for the purpose it serves. But I'm having issues... for one thing, on JBoss-3.0.2, for some reason the CustomerBean is getting ejbStored immediately after I get a customer from it. That means that if I have a list of 50 orders, and I loop thru that list to get the customer info for each order, I'm loading up the ENTIRE customer table from the database 50 times. That is SLOW and BAD. But using JBoss-2.4.4, the EJB container works differently and it only loads up the customers once, which makes it more efficient to have them all cached. I suppose my question boils down to this: With lots of orders and customers (and potentially other objects), what is a very good way to design the administrative system to optimize performance? Also, how can I control how often the EJB container calls ejbStore/ejbLoad? Can I control this at all? Thanks! Andy
Andy, It appears you are using the Entity beans in a way that goes against their design and purpose. I am sure you can come up with a way to work around this, but this is probably the wrong approach as no one will understand what you are doing...it breaks the cohesivness of your design. And, there are better ways..... I don't know where to even begin..... Hmmm... Have you read any good EJB books? I suggest the one from Orielly and I hear the one from Wiley (Mastering EJB) is good too. I read the Orielly one, and enjoyed it a lot. IBM and Sun have a free tutorial on EJB. I suggest before you invest too much time on this that you would actually save time by going through one of these tutorials.
Free IBM tutorial on EJB I also wrote a tutorial on EJB CMP/CMR and EJB QL. It is included in my signature. The examples work on Resin EE, WebLogic 7.0, JBoss and Sun RI. Once you master the basics then you should read EJB Design Patterns by Floyd Marinescu to go beyond the basics.