This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Problem with Hibernate Cache Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Problem with Hibernate Cache" Watch "Problem with Hibernate Cache" New topic
Author

Problem with Hibernate Cache

Jan Krystof
Greenhorn

Joined: Feb 12, 2011
Posts: 3
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 ;-)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Problem with Hibernate Cache
 
Similar Threads
Delete cached data and load from database
Auto increment key in Hibernate
Targetting specific Objects in session
caching master tables static data
Synchronize cached data across EJB containers