May 2015
Intermediate to advanced
234 pages
4h 18m
English
Some database modifications involve several SQL queries, for example, inserting an object with attributes spread across several tables. If one of the queries fails, we would want to undo any previous ones that were successful.
Here are the steps to make DAO methods transactional:
@EnableTransactionManagement to the Spring configuration class:@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan(basePackages = {"com.spring_cookbook.controllers", "com.spring_cookbook.dao"})
public class AppConfig {
…DataSourceTransactionManager bean to the Spring configuration:@Bean
public DataSourceTransactionManager transactionManager() { DataSourceTransactionManager ...Read now
Unlock full access