9

Got thru below statement at http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-cache-nonstrict

If the application only occasionally needs to update data (i.e. if it is extremely unlikely that two transactions would try to update the same item simultaneously)

What I got from above statement is if developer updates a object in his code, sometime he want to update in second level cache and sometime does not. Right? If yes how he will achieve it in his code. I mean where he needs to specify in his code that this time he wants to update in cache and other time not.

M Sach
  • 33,416
  • 76
  • 221
  • 314

1 Answers1

12

You got it wrong. What this means if that this strategy should be used when the entity is sometimes updated (so read-only does not apply), but that it's extremely unlikely that two concurrent transactions update the same item. For example, if you have thousands of users accessing the data, an one batch regularly update it, this option is the right one to choose: only one transaction updates the items at a time.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Thanks JB. Thats what actuaaly i am asking what is the code snippet that specify nonstrict read/write.As per my understanding it should be specified in our program instead of hbm.xml file.. Right? – M Sach Nov 18 '11 at 19:05
  • 1
    No. It's specified in the xml mapping file of the entity, or in the annotation describing the cache strategy for the entity. Why would it be in code? – JB Nizet Nov 18 '11 at 21:58
  • 1
    Thanks JB. What will happen when two concurrent transactions update the same item and if we choose non strict read/write option.Similarily what will happen when two concurrent transactions update the same item and if we choose read/write option – M Sach Nov 22 '11 at 18:33
  • See http://stackoverflow.com/questions/5079615/clustered-hibernate-cache-with-ehcache-nonstrict-vs-strict-read-write – JB Nizet Nov 22 '11 at 18:37