Sam Smith [https://community.jboss.org/people/ssmith2010] created the discussion

"Does a LockAcquisitionException Invalidate a Transaction?"

To view the discussion, visit: https://community.jboss.org/message/729932#729932

--------------------------------------------------------------
We're using Hibernate with SQL Server.  As you may know, SQL Server will 
occassionally throw deadlocks during SELECT statements.  We'd like to be able 
to capture this exception and retry the SELECT statement.  Our preference would 
be to do this globally in our EJB (which ises CMP), something like this:

{code}
public List getData(args...)

int retries=0;
boolean continue=true:

while (continue) {
try
     continue = false;
     {
          hibernate query to SELECT data
     } 
     catch (Exception ex)
     {
          if (ex instanceof LockAcquisitionException) {
               retries++;
               if (retries < 5) continue = true;
             }
     }
}

{code}

So the idea is to do the query, if there's a LockAcquisitionException, just 
retry a couple of time.  Our only concern is this -- does the exception 
invalidate the transaction?  We know the transaction is started when we enter 
the method, so if within the method we get an error, can we just retry or is 
the transaction no longer any good?  I'm sure it would be no good if we were 
doing an update and it forced a ROLLBACK, but we're unsure about in a 
non-update statement.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/729932#729932]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to