Kaltresian
Kaltresian

Reputation: 971

Example of EJB3 Mybatis and CMT

Somebody knows an example with EJB3 and Mybatis where the container controls the transaction, the only part of code I founded was:

SQLMapConfig.xml


<transactionManager type="EXTERNAL">
    <property name="SetAutoCommitAllowed" value="false"/>
    <dataSource type="JNDI">
        <property name="DataSource" value="java:comp/env/jdbc/sisds"/>
    </dataSource>
</transactionManager> 

But I have many questions, for example,

  1. When the container make the commit?
  2. When the container release the session to the pool?

Thanks in Advance

Upvotes: 2

Views: 2023

Answers (1)

AngerClown
AngerClown

Reputation: 6229

The container commits the transaction based on how your EJBs are configured. If you are using bean managed transactions, then you have to manage the UserTransaction yourself.

Regardless, you have to manage the MyBatis SqlSession yourself. Setting the tx type to EXTERNAL (MANAGED in Mybatis 3), simply means that MyBatis never calls commit on the DB connection - it relies on the container to commit.

Upvotes: 1

Related Questions