EJB3 Caching Instance Variables
Posted
by
Justin
on Stack Overflow
See other posts from Stack Overflow
or by Justin
Published on 2010-09-06T16:42:12Z
Indexed on
2010/12/24
17:54 UTC
Read the original article
Hit count: 401
Hi,
I've noticed some strange code on a project I am working on - its a SLSB EJB3, and it uses a private instance variable to maintain a cache of data (it even calls it dataCache or something), with a getter/setter. For EJB2 and bellow, this was a typical EJB antipattern - SLSBs are not meant to retain state in between invocations, theres no guarantee you'll see the same data on a subsequent invocation. One of my colleagues said maybe its ok in EJB3 (we don't have much EJB3 experience), but still, its a Stateless Session Bean - why is it trying to maintain state, this doesn't make sense.
Can anyone confirm if this is still a bad idea in EJB3 land, or if somehow it is ok?
Thanks if you can help, Justin
© Stack Overflow or respective owner