This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching objects in EJB and threading

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's a correct way to maintain a cache of objects queried from the database and make it available to remote clients through a SLSB?

Seems like it is very difficult to achieve this without violating EJB rules against managing threads and static variables (or by using singleton). In order to have objects shared by threads, they have to be stored in some static scope, and synchronization is a must.
[ December 10, 2008: Message edited by: Justin Chu ]
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin,

If you are using EJB 2.x, entity beans will do that for you, if you can stomach the complex development model. If you are using EJB 3.0, the way to do this would be through second-level caching. In Hibernate nomenclature, this is called an L2 cache: http://www.devx.com/dbzone/Article/29685. TopLink/EclipseLink has similar capabilities: http://wiki.tangosol.com/display/COH33UG/Using+Coherence+and+TopLink+Essentials. You can also always use Hibernate or JPA with EJB 2.x (very common scenario).

Regards,
Reza
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic