我对阿盟集团来说是相当新的。 我对交易问题感到困惑(与《非洲一体化行动计划》的退缩)。 我猜测,我可能会做一些基本错误的事情。 或与现有的冲突。
My Spring config file
<beans...>
<!-- This TX is I am interested in -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="mySqlDataSource"/>
</bean>
<bean id="registriesTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="registriesDataSource"/>
</bean> <!-- There are 2 datasorce for AS400 and a transaction for one of them-->
<aop:config>
<aop:advisor pointcut="execution(* se.unox.pejl.service.PejlAnalysisService.* (..))" advice-ref="txMySqlAdvice"/>
<! --- + many more -->
</aop:config>
<tx:advice id="txMySqlAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*" />
<tx:method name="cleanPejlValues" propagation="REQUIRED" rollback-for="Throwable"/>
</tx:attributes>
</tx:advice>
</beans>
我的服务执行
public class PejlAnalysisServiceImpl implements PejlAnalysisService, InitializingBean {
@Override
public void cleanPejlValues() {
List<String> idsToDelete= pejlDataDao.getPejlIds(Calendar.getInstance().getTime(), pejlType);
logger.debug("TRYING TO DELETE these IDS: " + idsToDelete);
numDeletedValues += cisternDao.deleteCistern(idsToDelete);
logger.debug("DELETED " + numDeletedValues);
numDeletedValues += pejlDataDao.deletePejlValues(idsToDelete);
}
}
My DAO, i
public class PejlDataDaoMySqlImpl extends GenericDaoImpl<PejlDataInValue,String> implements PejlDataDao {
@Override
public int deletePejlValues(List<String> pejlIds) {
throw new RuntimeException("THROW INTENTIONALLY");
}
}
我想,CisternDao(Table tbl_cistern)所删除的行文,在我(有意)从另一个原谅从父母桌上删除数据的Dao那里 throw出例外之后再行。
然而,我的退步并不奏效。 表tbl_cistern数据仍在输入。
我做了什么错误? (我正在使用第3条第1款、第3条第1款、第3条第3款、第13条第1款)
================================================================================================================================================================================================================================================================
EDIT。
Here is my AOP StackTrace. It does saying Rolling back, but my rows from first table is still gone. Its an existing application. Wonder if DomainServiceImpl TX is interfering.
2011-10-12 11:46:27,726 DEBUG - Creating new transaction with name [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-Throwable
2011-10-12 11:46:27,726 DEBUG - Creating new transaction with name [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-Throwable
2011-10-12 11:46:27,726 DEBUG - Acquired Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] for JDBC transaction
2011-10-12 11:46:27,726 DEBUG - Acquired Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] for JDBC transaction
2011-10-12 11:46:27,727 DEBUG - Switching JDBC Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] to manual commit
2011-10-12 11:46:27,727 DEBUG - Switching JDBC Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] to manual commit
2011-10-12 11:46:27,727 DEBUG - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] to thread [http-8080-1]
2011-10-12 11:46:27,727 DEBUG - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] to thread [http-8080-1]
2011-10-12 11:46:27,727 DEBUG - Initializing transaction synchronization
2011-10-12 11:46:27,727 DEBUG - Initializing transaction synchronization
2011-10-12 11:46:27,728 DEBUG - Getting transaction for [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues]
2011-10-12 11:46:27,728 DEBUG - Getting transaction for [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues]
2011-10-12 11:46:27,729 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,729 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,729 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,729 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,729 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,729 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,730 DEBUG - Bound value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] to thread [http-8080-1]
2011-10-12 11:46:27,730 DEBUG - Bound value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] to thread [http-8080-1]
2011-10-12 11:46:27,730 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,730 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,734 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,734 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,734 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,734 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,734 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,734 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,734 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,734 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,735 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,735 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] bound to thread [http-8080-1]
2011-10-12 11:46:27,735 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,735 DEBUG - Participating in existing transaction
2011-10-12 11:46:27,735 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,735 DEBUG - Getting transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,735 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,737 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,737 DEBUG - Completing transaction for [se.unox.pejl.service.impl.DomainServiceImpl.getDomainData]
2011-10-12 11:46:27,737 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,737 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,789 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:27,789 DEBUG - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] bound to thread [http-8080-1]
2011-10-12 11:46:28,396 DEBUG - Completing transaction for [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues] after exception: java.lang.RuntimeException: THROWN INTENTIONALLY
2011-10-12 11:46:28,396 DEBUG - Completing transaction for [se.unox.pejl.service.impl.PejlAnalysisServiceImpl.cleanPejlValues] after exception: java.lang.RuntimeException: THROWN INTENTIONALLY
2011-10-12 11:46:28,396 DEBUG - Applying rules to determine whether transaction should rollback on java.lang.RuntimeException: THROWN INTENTIONALLY
2011-10-12 11:46:28,396 DEBUG - Applying rules to determine whether transaction should rollback on java.lang.RuntimeException: THROWN INTENTIONALLY
2011-10-12 11:46:28,396 DEBUG - Winning rollback rule is: RollbackRuleAttribute with pattern [Throwable]
2011-10-12 11:46:28,396 DEBUG - Winning rollback rule is: RollbackRuleAttribute with pattern [Throwable]
2011-10-12 11:46:28,396 DEBUG - Triggering beforeCompletion synchronization
2011-10-12 11:46:28,396 DEBUG - Triggering beforeCompletion synchronization
2011-10-12 11:46:28,397 DEBUG - Removed value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] from thread [http-8080-1]
2011-10-12 11:46:28,397 DEBUG - Removed value [org.springframework.orm.hibernate3.SessionHolder@160088f] for key [org.hibernate.impl.SessionFactoryImpl@1a0280d] from thread [http-8080-1]
2011-10-12 11:46:28,397 DEBUG - Initiating transaction rollback
2011-10-12 11:46:28,397 DEBUG - Initiating transaction rollback
2011-10-12 11:46:28,397 DEBUG - Rolling back JDBC transaction on Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver]
2011-10-12 11:46:28,397 DEBUG - Rolling back JDBC transaction on Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver]
2011-10-12 11:46:28,398 DEBUG - Triggering afterCompletion synchronization
2011-10-12 11:46:28,398 DEBUG - Triggering afterCompletion synchronization
2011-10-12 11:46:28,398 DEBUG - Clearing transaction synchronization
2011-10-12 11:46:28,398 DEBUG - Clearing transaction synchronization
2011-10-12 11:46:28,398 DEBUG - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] from thread [http-8080-1]
2011-10-12 11:46:28,398 DEBUG - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@6113e0] for key [org.apache.commons.dbcp.BasicDataSource@ee003d] from thread [http-8080-1]
2011-10-12 11:46:28,399 DEBUG - Releasing JDBC Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] after transaction
2011-10-12 11:46:28,399 DEBUG - Releasing JDBC Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] after transaction
2011-10-12 11:46:28,399 DEBUG - Returning JDBC Connection to DataSource
2011-10-12 11:46:28,399 DEBUG - Returning JDBC Connection to DataSource
2011-10-12 11:30:36,577 DEBUG - Releasing JDBC Connection [jdbc:mysql://localhost:3306/pejldatastorenorway?autoReconnect=true, UserName=dbpejl@localhost, MySQL-AB JDBC Driver] after transaction