jotm真是个烂东西,不能回滚,导致系统出现了很多问题,深受其害,决心换个东东,在网上找到了atomikos,做下记录
<? xml version="1.0" encoding="UTF-8" ?>
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" >
< beans default-autowire ="byName" >
< bean id ="atomikosUserTransaction" class ="com.atomikos.icatch.jta.UserTransactionImp" >
</ bean >
< bean id ="atomikosTransactionManager" class ="com.atomikos.icatch.jta.UserTransactionManager" init-method ="init" destroy-method ="close" >
<!-- when close is called, should we force transactions to terminate or not? -->
< property name ="forceShutdown" >< value > true </ value ></ property >
</ bean >
< bean id ="txManager" class ="org.springframework.transaction.jta.JtaTransactionManager" >
< property name ="transactionManager" >< ref bean ="atomikosTransactionManager" /></ property >
< property name ="userTransaction" >< ref bean ="atomikosUserTransaction" /></ property >
</ bean >
< bean id ="auditDS"
class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" >
< property name ="uniqueResourceName" >< value > mysql/cnaudit </ value ></ property >
< property name ="xaDataSourceClassName" >
< value > com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </ value >
</ property >
< property name ="xaProperties" >
< props >
< prop key ="user" > XXX </ prop >
< prop key ="password" > XXX </ prop >
< prop key ="URL" >
XXX </ prop >
</ props >
</ property >
< property name ="poolSize" >< value > 50 </ value ></ property >
</ bean >
< bean id ="oracleDS"
class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" >
< property name ="uniqueResourceName" >< value > oracle/cnaudit </ value ></ property >
< property name ="xaDataSourceClassName" >
< value > oracle.jdbc.xa.client.OracleXADataSource </ value >
</ property >
< property name ="xaProperties" >
< props >
< prop key ="user" > XXX </ prop >
< prop key ="password" > XXX </ prop >
< prop key ="URL" >
XXX
</ prop >
</ props >
</ property >
</ bean >
< bean id ="sqlMapClient"
class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
< property name ="configLocation"
value ="classpath:ibatis/SqlMapConfig.xml" />
< property name ="dataSource" ref ="auditDS" />
</ bean >
< bean id ="sqlMapClientTemplate"
class ="org.springframework.orm.ibatis.SqlMapClientTemplate" />
< bean id ="oraSqlMapClient"
class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
< property name ="configLocation"
value ="classpath:ibatis/SqlMapConfig-oracle.xml" />
< property name ="dataSource" ref ="oracleDS" />
</ bean >
< bean id ="oraSqlMapClientTemplate"
class ="org.springframework.orm.ibatis.SqlMapClientTemplate" >
< property name ="sqlMapClient" ref ="oraSqlMapClient" />
</ bean >
</ beans >
在配置一下事物管理,ok
<?
xml version="1.0" encoding="UTF-8"
?>
< beans xmlns ="http://www.springframework.org/schema/beans"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop ="http://www.springframework.org/schema/aop"
xmlns:tx ="http://www.springframework.org/schema/tx"
xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire ="byName" default-lazy-init ="true" >
<!-- 支持 @AspectJ 标记 -->
< aop:aspectj-autoproxy />
< aop:config proxy-target-class ="true" >
< aop:advisor pointcut ="execution(* *Facade.*(..))" advice-ref ="txAdvice" />
< aop:advisor pointcut ="execution(* *Manager.*(..))" advice-ref ="txAdvice" />
</ aop:config >
< tx:advice id ="txAdvice" >
< tx:attributes >
< tx:method name ="get*" read-only ="true" />
< tx:method name ="find*" read-only ="true" />
< tx:method name ="has*" read-only ="true" />
< tx:method name ="locate*" read-only ="true" />
< tx:method name ="*" />
</ tx:attributes >
</ tx:advice >
</ beans >
< beans xmlns ="http://www.springframework.org/schema/beans"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop ="http://www.springframework.org/schema/aop"
xmlns:tx ="http://www.springframework.org/schema/tx"
xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire ="byName" default-lazy-init ="true" >
<!-- 支持 @AspectJ 标记 -->
< aop:aspectj-autoproxy />
< aop:config proxy-target-class ="true" >
< aop:advisor pointcut ="execution(* *Facade.*(..))" advice-ref ="txAdvice" />
< aop:advisor pointcut ="execution(* *Manager.*(..))" advice-ref ="txAdvice" />
</ aop:config >
< tx:advice id ="txAdvice" >
< tx:attributes >
< tx:method name ="get*" read-only ="true" />
< tx:method name ="find*" read-only ="true" />
< tx:method name ="has*" read-only ="true" />
< tx:method name ="locate*" read-only ="true" />
< tx:method name ="*" />
</ tx:attributes >
</ tx:advice >
</ beans >