• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with Hibernate Cache

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

i also had the same problem: After i updated an entity to new value in SESSION1 and i fetched the same entity afterwards in SESSION2, i got old values. I even checked in my DB after closing SESSION1 that new values are present in my db.

There was one not-nice workaround: when I wanted to read updated data, i opend and commited a transation: session.beginTransaction().commit();

However, in my case the problem was in INNODB settings for mysql database. The default isolation level for INNODB is REPEATABLE READ -- I found it here hibernate forum. The solution is in changing the global transaction isolation level to READ_COMMITTED (2) or SERIALIZABLE (8). Check the java.sql.Connection for these isolation levels.

Put the following in your config.hbm.xml

or


all the best
xhanness

PS: do not forget do flush() before closing the session ;-)
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic