ibatis:绕过iBATIS的事务管理来源: 发布时间:星期四, 2009年2月12日 浏览:195次 评论:0
不管你信不信 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 例如: view plaincopy to clipboardpr ![]() public ![]() ![]() Reader reader = Resources.getResourceAsReader("sql-map-config.xml"); SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(reader); List list = smc.queryForList("Test.testQuery", null); ![]() ![]() ![]() } public ![]() ![]() Reader reader = Resources.getResourceAsReader("sql-map-config.xml"); SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(reader); List list = smc.queryForList("Test.testQuery", null); ![]() ![]() ![]() }上面代码已经具有隐式事务了 ![]() ![]() ![]() ![]() ![]() 至于如何绕过事务我稍后在讲 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 另外 ![]() ![]() ![]() ![]() ![]() ![]() ![]() JDBC.DefaultAutoCommit选项成了鸡肋 ![]() ![]() ![]() ![]() 由于spring ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() view plaincopy to clipboardpr ![]() /** * * Description:绕过ibatis事务管理 ![]() ![]() * * @throws SQLException * @throws IOException * @mail [email protected] * @since:Jul 13, 2008 5:28:32 PM */ public ![]() ![]() Reader reader = Resources.getResourceAsReader("sql-map-config.xml"); SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(reader); Connection conn = null; List lits = null; boolean isAutoCommit = false; try { conn = smc.getDataSource ![]() ![]() isAutoCommit = conn.getAutoCommit ![]() conn. ![]() smc. ![]() lits = smc.queryForList("Test.testQuery", null); } finally { try { conn. ![]() } finally { conn.close ![]() } } ![]() ![]() ![]() } /** * * Description:绕过ibatis事务管理 ![]() ![]() * * @throws SQLException * @throws IOException * @mail [email protected] * @since:Jul 13, 2008 5:28:32 PM */ public ![]() ![]() Reader reader = Resources.getResourceAsReader("sql-map-config.xml"); SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(reader); Connection conn = null; List lits = null; boolean isAutoCommit = false; try { conn = smc.getDataSource ![]() ![]() isAutoCommit = conn.getAutoCommit ![]() conn. ![]() smc. ![]() lits = smc.queryForList("Test.testQuery", null); } finally { try { conn. ![]() } finally { conn.close ![]() } } ![]() ![]() ![]() } 通过这种思路方法 ![]() ![]() ![]() 不过 ![]() ![]() 0
相关文章读者评论发表评论 |
|