-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Force query result refresh
PostPosted: Thu Jun 14, 2012 10:18 am 
Newbie

Joined: Tue Nov 29, 2011 5:43 am
Posts: 5
Hi,
I have a problem with hibernate cache.
The best way to explain will be following example:
I have a query :
Code:
getCurrentSession().createQuery("from User").list().size()

which return 0.
In other thread and other session i adding new User, so database User table contains 1 user record, although when i one more time make a query:
Code:
getCurrentSession().createQuery("from User").list().size()

I got still 0 but i should got 1.

Is any way to clear query result, which was cached as I guess ?
By the way - If i call query only one time, then i got 1, but because I made this query earlier hibernate cached one and I got 0 again.

Thanks for any help.


Top
 Profile  
 
 Post subject: Re: Force query result refresh
PostPosted: Wed Nov 07, 2012 11:20 am 
Newbie

Joined: Tue Nov 29, 2011 5:43 am
Posts: 5
Because nobody didn't ask for my question I would like to explain what the problem was.
So, this problem was caused not by hibernate cache, but by REPEATABLE READ isolation transaction level on database.
the first query see current data and every next query see the snapshot made by first query, not a current value (if the query is still in the same transaction).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.