What is the correct usage of the Seam @Transactional annotation?
I'm a bit confused about the meaning of values used in the @Tr开发者_开发问答ansactional annotation, specifically @TransactionPropagationType. Perhaps Gavin thought it would be obvious enough from the name of each enum type and decided not to document the actual meaning... Be that as it may I have no clue what any of the following actually mean: MANDATORY, NEVER, REQUIRED, SUPPORTS. Anyone out there who does?
From the book Seam in Action the enum tyes mean that :
REQUIRED Indicates that a transaction is required to execute the method. If a transaction isn’t active, Seam will begin a new transaction. This is the default type.
SUPPORTS Indicates that the method is permitted to execute in the presence of an active transaction, but it won’t begin a transaction if one isn’t active.
MANDATORY Indicates that an active transaction is required to execute the method. A runtime exception is thrown if a transaction isn’t already in progress.
NEVER Indicates that a transaction shouldn’t be active when this method is called. A runtime exception will be thrown if a transaction is active.
Hope this helps ;-)
These propogation types are almost the same in different declarative transaction management implementations (EJB3, Spring and Seam). Curiously, they are documented in javadoc only in Spring.
axtavt was right, the meaning is the same as in Spring. The documentation for Seam 3 is more thorough, so the TransactionPropagation enum is better explained
精彩评论