Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

A question with cache attribute usage

 
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
 
author and cow tipper
Posts: 5000
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 ?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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 .
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic