Next you need to annote your dao with @Transactional. The source code can be found at github:
@Configuration
@EnableTransactionManagement
public class JdbcConfig {
@Bean
public DataSource dataSource() {
//config datasource
}
@Bean
public PlatformTransactionManager txManager() {
return new DataSourceTransactionManager(dataSource());
}
@Bean
public MyDao myDao() {
MyDaoJdbc dao = new MyDaoJdbc();
dao.setDataSource(dataSource());
return dao;
}
}
https://github.com/zhentao/spring-jdbc-transaction-example
No comments:
Post a Comment