-->
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.  [ 3 posts ] 
Author Message
 Post subject: Stale data across sessions
PostPosted: Thu Jun 26, 2008 12:22 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
Is there any way that an entity can be evicted from all peristence context caches (first level cache) across all sessions?

In my web application if user A has a list of Bookings and user B updates some of them; for example changing a status to "accepted", then the list that user A is working from is no longer accurate - ie. it is stale.

I can call a refresh() to load the data from the database, however the user would have to know which Booking to refresh. Refreshing all of them is an option, but an expensive one.

Methods such as session.evict() only operate on the current session and don't affect other user's sessions.

How do other people handle this situation?

Thanks,

Damian.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 5:59 pm 
Newbie

Joined: Fri Mar 09, 2007 2:01 am
Posts: 5
Are you sure you don't mean the second level cache? L1 caches are only ever kept for the active session and then discarded. The only time another session would see the same data is on the second level cache.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 11:36 am 
Newbie

Joined: Tue May 13, 2008 12:34 pm
Posts: 8
Location: Santiago de Chile
Hi, I'm the same problem with the second level cache disable.

After a some debugging, I have more antecedents about the problem.

My tomcat open two threads in my test environment, the first thread T1 and second T2. In both thread we query for the same object, an object A with id '1' from the table 'A_TABLE', where the age of A is 3 (A.age=3). Then we update the age of A in one of this thread, suppose T1 the other tread have stale data. Now in T1 A.age = 4 and finally make the commit. Now we query again the age of A in both threads, in T1 A.age=4 and in T2 A.age=3, and in the DB A_TABLE.age=4.

For any reason the hibernate session in T2 isn't refresh the data from de database. For each query, we are making a new SOA petition, and hibernate are using some threads for attending our petitions.

The current_session_context_class is setted to 'thread'.


[Time | A.age in T1 | A.age in T2 | A.age in DB]
[t1 | 3 | 3 | 3]
[t2 | 4 | 3 | 4]
[t3 | 4 | 3 | 4]

The session life cycle is managed by spring and the transactions are initialized by hand with session.getCurrentSession().beginTransaction().

Please, any help will be appreciate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.