Forums Register Login
Best practice for looking up.
Hey all.
imagine the following scenario.
I have a stateless bean that acts as a session facade for entity bean.
as you know, this facade will try to locate entity's home.
usually I put the code that looks for entity's home in the setSessionContext( ) method.
when using a statefull bean as a facade, we can look for entity's home in ejbCreate( ) method and set the home reference to null in ejbPassivate( ) method and look up for the home again in ejbActiviate( ) method.
my question is, which approach is better :
using setSessionContext( ) or
using ejbCreate( ) and ejbPassivate( ) and ejbActivate( ) methods.
(I mean better for performance and memory)
are there circumnstances that I should use a specific way ?
I guess I would wonder why you feel it necessary to null the home interface during ejbPassivate only if you set it during ejbCreate. For one thing, you don't really need to null it at all, it will be properly serialized/deserialized which can save you a lookup during ejbActivate. But if you really don't want it passivated, does it eally matter where it was set?

As to whether to set the home interface during setSessionContext or ejbCreate, that is pretty much your call. I normally do not put initialization code in setSessionContext, I prefer to use ejbCreate for that.

This thread has been viewed 435 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 18, 2018 15:11:12.