O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declarative ACID using @Transactional

Declarative transactions are highly recommended because they keep transaction management out of business logic and are easy to configure. Let's see an example of annotation-based declarative transaction management.

Let's use the same example that was used in the Spring JDBC section. In our example, we are using JdbcTemplate for database interaction. So, we need to add DataSourceTransactionManager in our Spring configuration file.

The following is the Spring bean configuration class:

@Configuration@EnableTransactionManagementpublic class AppConfig {    @Bean    public DataSource dataSource() {        DriverManagerDataSource dataSource = new         DriverManagerDataSource();  dataSource.setDriverClassName("org.postgresql.Driver"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required