Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BackingBean for caching data?

 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again!

You there're many Use Cases where user first asks for a list of something (let's say a list of cars) and in the next 'click' it asks for the details of a car from the previously given list. So, if we used JSF/EJB we could have a CarBackingBean get the list using the CarEJB (SLSB as a DAO). Here's my question: should the BackingBean keep the list in order not to ask the EJB in future requests (calling DB again) or should my BBean forget about the list and ask for a selected car details in the next request.

I think it's better to use the BBean as a cache, I mean, let it be a Session Scoped Backing Bean to avoid going to database once again. Anyway, it should not be much data as I used pagination so the BB only would use page-length cars at the same time FOR EACH USER... That's what scares me, maybe there are many users and it's better to have a Request Scoped BB and query to DB everything everytime. What do you think?

By the way, if you finally decide to cache this data, would you choose any other place than the BackingBean?

Thank you very much!

antonio
 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The downside BBean approach is stale data, you could use a ORM solution that has a Hibernate type second level cache.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic