简体   繁体   English

EJB3 Mybatis和CMT的示例

[英]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: 有人知道EJB3和Mybatis的示例,其中容器控制事务,我建立的唯一代码部分是:

SQLMapConfig.xml 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 提前致谢

The container commits the transaction based on how your EJBs are configured. 容器根据您的EJB的配置方式提交事务。 If you are using bean managed transactions, then you have to manage the UserTransaction yourself. 如果您正在使用bean管理的事务,则必须自己管理UserTransaction

Regardless, you have to manage the MyBatis SqlSession yourself. 无论如何,您都必须自己管理MyBatis SqlSession。 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. 将tx类型设置为EXTERNAL (在Mybatis 3中进行了MANAGED ),仅意味着MyBatis永远不会在数据库连接上调用commit-它依赖于容器进行提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM