I am new to Spring. I am using @Transactional annotation for my dao methods:
@Transactional public Person getById(long id) { return new Person(jdbcTemplate.queryForMap(...)); } @Transactional public void save(Person person) { jdbcTemplate.update(...); }
and I created a transaction manager as follows:
<tx:annotation-driven transaction-manager="txManager" /> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean>
The problem is that when my client code calls dao.save(..) and then dao.getById(4) , this happens in two separate transactions. How can I wrap these 2 calls in a single database transaction? Ideally, not doing this programmatically.
thanks
source share