-->
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.  [ 1 post ] 
Author Message
 Post subject: Transactions Tomcat Hibernate MySQL on Linux vs Windows
PostPosted: Sat Dec 19, 2009 3:10 am 
Newbie

Joined: Thu Oct 02, 2008 9:15 am
Posts: 3
Hi!

I use the classic HibernateSessionRequestFilter as described in: http://www.hibernate.org/43.html

If I update a table in the database, that update is visible to concurrent requests on a windows server. But not on a Linux server. To fix that on linux I had to make the doFilter-method synchronized

Code:
public synchronized void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
...
log.debug("Starting a database transaction");
            sf.getCurrentSession().beginTransaction();  // IF 2 requests hit this before commit() is called later on, then they will both see the updated table as it was befor any of the requests started. This is only true on linux. Thus this method is now synchronized to prevent that for happening
            chain.doFilter(request, response);
            sf.getCurrentSession().getTransaction().commit();
...



Most of the applications operations are read only. So synchronized is perhaps not good for preformance.

What is the correct way to handle this issu?


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

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.