Hi! Profiling application I see that spring doesn't intercept transaction. The DAO interface is marked with annotation @Transactional, so spring should create proxy from such beans and wrap calls in transaction. Neither I see proxies in profiler nor data is rolled back when throwing Runtime exception in transactional methods. Please help. Spring 3.x.
Method doSomething() in service is @Transactional and all dao instance methods. Please help, what I configured wrong???
Code:.......... <tx:annotation-driven/> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> ......... </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="userDao" class="com.test.dao.UserDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="userService" class="com.test.service.UserServiceimpl"> <property name="userDao" ref="userDao" /> </bean> .......
Attachment 4596Code:public interface UserService { User loadUserById(long userId); void doSomething(); } public class UserServiceimpl implements UserService { @Transactional @Override public void doSomething() { User user = loadUserById(1); user.fillUpMoney(999); userDao.update(user); throw new RuntimeException("Should be rollback"); } ..... } @Transactional public interface BaseDao<T> { ... }


Reply With Quote
