ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lieven De Keyzer" <lieven_dekey...@hotmail.com>
Subject transactions
Date Tue, 24 May 2005 18:27:58 GMT
At  http://www.reumann.net/struts/ibatisLesson1/step6.do
this is an example in a ibatis/struts tutorial

public int update(String statementName, Object parameterObject) throws 
DaoException {
    int result = 0;
    try {
        sqlMap.startTransaction();
        result = sqlMap.executeUpdate(statementName, parameterObject);
        sqlMap.commitTransaction();
    } catch (SQLException e) {
        try {
            sqlMap.rollbackTransaction();
        } catch (SQLException ex) {
            throw new DaoException(ex.fillInStackTrace());
        }
        throw new DaoException(e.fillInStackTrace());
    }
    return result;
}

Is it necessary to have a transaction started for just 1 statement 
execution?

Also, what's the better way? Doing a transaction in a Service class, that 
has multiple DAO's, or doing it in the DAO class, doing different statements 
in one method? Or is there no difference?



Mime
View raw message