Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question with cache attribute usage

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am trying to clear some doubts with Hibernate for getting a Job ASAP . so please help me .


If one configures Ehcache as second level cache with Hibernate and uses a READ_WRITE strategy as say <cache usage="read-write"/>

"Then my understanding with respect to above is that " Whenever there is a change of the entity at the database level the cache is also updated simultaneously " please tell me if i am right or wrong on this .

Waiting for your replies
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody please help
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If someone underwrites the data in the database, and your Hibernate Session doesn't have a lock on that data, I can't see how Hibernate could update that second level cache. It's not really just a deficiency in Hibernate. It's just a matter of controlling how many different fingers are in the database pie.

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cameron ,

You had mentioned a great point in using the risk of read - write cache . So please tell me how can i lock the resources when working with read-write cache ?


Do i need to problematically lock the resources or the Hibernate Framework manages this ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pessimistic locking of resources in a database backed application is almost always a bad idea. It turns a resource designed to support concurrent access to one that only supports serial access. You would normally use an optimistic locking mechanism to check before update if things have changed (to prevent lost updates) and in the case of a second level cache you would also carefully choose the data you allow in this cache, since frequently updated data is not a good candidate for a cache.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point Paul . Thank you .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic