Hello Harald,

I am not quite sure what your question is.

When executing an SQL Statement we catch exceptions of type 
java.sql.SQLException and wrap them inside a StatementFailedException (this is 
done in DBDatabase.executeSQL(...)). But it is also possible that you get an 
UnexpectedReturnValueException.
We do this to perform logging and to provide a consistent exception interface 
(org.apache.empire.exceptions.EmpireException).

You may catch this exception in your code and perform a rollback.
Usually you may want to perform several updates inside a single transaction 
like this:

        try {
                // Update three records in one transaction
                rec1.update(conn);
                rec2.update(conn);
                rec3.update(conn);
                db.commit(conn);
        } catch(Exception e) {
                db.rollback(conn);
        }

Regards,
Rainer

> from: Harald Kirsch [mailto:[email protected]]
> to: [email protected]
> re: Transactions, Exceptions and Empire-db
> 
> Hi,
> 
> looking at the FAQ it says that transactions are my own business when using
> empire-db. Fair enough.
> 
> Any exceptions thrown during db operations within a transaction should
> result in a rollback, but when I look at DBrecord.update(), it does not throw
> any exceptions.
> 
> Despite the fact that Martin Fowler proclaims "the debate is over"
> (cited here:
> http://theknowledge.me.uk/mywiki/concepts/exceptions/The%20Need%20
> to%20Document%20Runtime%20Exceptions.html)
> and wants us to only use unchecked exceptions, I am now left to explore the
> source code to figure out into which unchecked exception the inevitable
> SQLException is converted during DBrecord.update(). (It is
> StatementFailedException.)
> 
> And I need to know, because I must catch it to perform the rollback --- at
> least this is what I reckon.
> 
> Am I right or am I wrong?
> 
> Harald.

Reply via email to