I have a CMP EJB in the JBOSS server,
i find that each time i get the value of the instance,
it call the ejbLoad and ejbStore method..
is there any way that can cache the instance?
- CMP EJB PROBLEM~ by Barri Jansen on October 25 2002 10:51 EDT
- CMP EJB PROBLEM~ by girish jha on November 01 2002 01:56 EST
- CMP EJB PROBLEM~ by Simon Kinahan on November 05 2002 13:30 EST
- Re: CMP EJB PROBLEM~ by Nongban luwang on May 23 2008 04:12 EDT
This is because the ejbActivate/ejbPasivate is called. According the J2ee specs ejbLoad and ejbStore should be called. This doesn't mean that the container is always going to your database.
But the speed of retriving data is very slow,
is there any way that i can speed up this??
this is the advantage of EJB over other component.
When u call some entity bean fom ur JSP it retreives data from persistence storage device and stores in the instanc of entity bean. when u modify this data (which has been preented to u) after somebody else has modified u will not be allowed to modify else u will be presented new data which was modifie by somebody else before u. At that time ejbLoad() is called before calling ejbStore() to check whether same instance is there or not which was presented to u on ur request. If the same record is there ur new record will be updated else not.
This is why when u are performing any database opeartion ejbLoad and ejbLoad is to be called. right.
this is one of the features of EJB.
Any queries are welcome
The solution to your problem is in the locking strategy, specified in JBoss deployment descriptors. Refer to the JBoss developer's guide, which is worth the $10 it costs.
In any server, there are multiple locking options for entity beans. By default, ejbLoad() and ejbStore() will be invoked each time, to ensure correct behavior in a clustered environment. If you don't want this, there is normally an option in which the server assumes that data can be modified only by entity bean methods, and avoids calling ejbLoad() when an instance is active. Of course this won't work in a cluster and won't work if any other process can update the underlying data.
Finally, depending on your data access requirements, entity beans may not be the best solution, especially where performance is concerned.
Rod Johnson, author of Expert One-On-One J2EE Design and Development, which discusses these issues at length.
As other people have already said, by default EJB containers call ejbLoad() and ejbStore() in every transaction, in order to ensure they are loading and modifying the right data if others are also accessing the database.
Some application servers have an option to avoid calling ejbLoad() if you're sure noone else is accessing the database (JBoss does this). Some also let you use optimistic locking, which does the same thing even when someone else is accessing the database, with the downside that it might cause your transaction to fail and need to be rolled back. I don't think JBoss supports this in CMP.
Various vendors also supply caching products, which let your application servers share a cache of data that has been read from the database in the past and can be reused. Usually you need to buy this functionality separately. Vendors include Tangosol, Gemstone, and (ahem) Isocra. I happen to think our livestore product is pretty good :-)
i am new to ejb and to this site ,i dont now where to type the question??????? m using ejb 2.0 ,in weblogic_cmp_rdbms.xml inside the doctype ......www.bea.com.... .......cmp.wl81..dtd here it shows like unable to connect www.bea.com; i am using hibernate too,but org/hibernate.Session classdefnotfoundexception ; all the classpath are set in possible ways