我正在使用jersey with jersey rest Webservice。我已经使用spring transaction支持进行事务管理。但交易不起作用。这是我的配置:
datasource.xml
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" p:driverClass="com.mysql.jdbc.Driver"
p:jdbcUrl="jdbc:mysql://localhost:3306/test" p:user="pass" p:password="root"
p:acquireIncrement="5" p:idleConnectionTestPeriod="60" p:maxPoolSize="100"
p:maxStatements="50" p:minPoolSize="10" />
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- Enable Annotation based Declarative Transaction Management -->
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
dao classess:
import org.springframework.transaction.annotation.Transactional;
@Transactional
public class CustomerDao {
public void insertCustomer() {
//insertion with plain jdbc like catch exception and rethrow it
}
}
来电者
Product product= new Product();
customerDao.insertCustomer(product.getCustumer());
prderDao.insertOrder(product.getOrder());
ctx.close();
isssue&gt;在product.getOrder中抛出异常后,数据仍然存在于customer表
中有人能帮助我吗?先谢谢