0

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.

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
Jason H
  • 51
  • 3
  • This might be dependent on your case. Questions like "which one is better" are dependent on what goal must be reached. What are you trying to do? – siebz0r Jun 07 '12 at 08:10

1 Answers1

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