3 回答

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
Programmatic Transaction Management MyBatis SqlSession provides you
with specific methods to handle transactions programmatically. But
when using MyBatis-Spring your beans will be injected with a Spring
managed SqlSession or a Spring managed mapper. That means that Spring
will always handle your transactions.You cannot call SqlSession.commit(), SqlSession.rollback() or
SqlSession.close() over a Spring managed SqlSession. If you try to do
so, a UnsupportedOperationException exception will be thrown. Note
these methods are not exposed in injected mapper classes.Regardless of your JDBC connection's autocommit setting, any execution
of a SqlSession data method or any call to a mapper method outside a
Spring transaction will be automatically committed.If you want to control your transactions programmatically please refer
to chapter 10.6 of the Spring reference manual. This code shows how to
handle a transaction manually using the PlatformTransactionManager
described in section 10.6.2.
添加回答
舉報(bào)