from : http://blog.sina.com.cn/s/blog_72ef7bea0101h3zr.html
Label: transactionalanotationjavaeespring |
Category: Web.JavaEE |
Add the following Service and Transactional annotations to my Srping business layer today:
The result always does not recognize propagation, timeout and rollbackFor. Later, I found out that I introduced the wrong class definition. I should have used Spring's
org.springframework.transaction.annotation.Transactional
, but JavaEE was introduced for CDI (Contexts and Dependency Injection for the Java EE platform, context and dependency injection) bean's
javax.transaction.Transactional
, it's really easy to get confused if you don't pay attention.
@Service
@Scope(BeanDefinition.SCOPE_SINGLETON)
@Transactional(propagation=Propagation.REQUIRED,
timeout=600,
rollbackFor=Exception.class)