-->
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: Hibernate Transactions and Lock Acquisition Exceptions
PostPosted: Wed Aug 06, 2008 4:52 pm 
Newbie

Joined: Wed Aug 06, 2008 2:18 pm
Posts: 5
I'm attempting to debug some previously developed code that appears to have been written session-per-operation style, and we're continually seeing 1) performance issues and 2) Lock Acquisition Exceptions (LAE). Of course, being that it's session-per-operation style, all of the DAOs (about 50 or so) all have session management embedded. In one particular case, we have a simple call to save one row to one table that results in updates to other rows in the same table (as well as a few other updates in other tables) then retrieves the inserted record back by doing another get from a new session, and this regularly gets an LAE - which doesn't surprise me. I've tried wrapping this in a transaction (because it wasn't before), but the exception persists. We've even received this except during read-only requests due to write-locks still active (we can replicate this during load testing where we save repetitively and try to load a read-only view of the page containing newly saved posts).

We're using Spring 2.0, Hibernate 3, and MS SQL 2005. The Model classes are annotated, and Hibernate and DAOs are configured via Spring XML applicationContexts. I'm truly at a loss to resolve these recurring problems in a way that doesn't require us to rewrite every DAO, site-wide, immediately. I'm not sure if there's a quick, temporary way to set transaction levels, to hopefully bypass the LAE problem while we work on rewriting the app and DAOs to be session-per-request.

Example DAO Method
Code:
    public void savePost(Post post) {
        Session session = getSession();
        Transaction tx = session.beginTransaction();
        try{
            getHibernateTemplate().saveOrUpdate(post);
            tx.commit();
        }catch(Exception e){
            tx.rollback();
        }finally{
            releaseSession(session);
        }
    }


Any suggestions would be greatly appreciated.


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.