I'm trying to determine which methodology for caching is better using an EJB3 Singleton session bean with HashMap or using 2nd level Caching with @Cacheable annotation on Entity.
Asked
Active
Viewed 357 times
1 Answers
0
Not sure what you mean by singleton SessionBean, but it doesn't sound good. Use @Cacheable.

James
- 17,965
- 11
- 91
- 146
-
Hi James, you can use an EJB3 Singleton session bean and add a HashMap as cache, and the container-concurrency-management will handle synchronization. So essentially, by adding a HashMap in a Singleton, it becomes like a 2nd level cache. So to my question, do I really need to do @Cacheable at the entity level in JPA to have a 2nd level cache or simply just use a HashMap as cache in the Singleton session bean. Thanks – Jason H Jun 05 '12 at 14:28