org.springframework.transaction.annotation.Transactional vs javax.jdo.annotations.Transactional
Question
When using spring @Transcational
on service layer, I will need to put <annotation driven>
on xml file.
I'd like to know
Can
javax.jdo.annotations.Transactional
be used on service layer just like spring does? Without needing to configure xml files. etc?Can
javax.jdo.annotations.Transactional
be used on service layer independent of whether I use hibernate/jpa/jdo at the dao layer? Do I need to configure any other things beside marking methods with@Transactional
?Are there any differences/limitations between
javax.jdo.annotations.Transactional
andorg.springframework.transaction.annotation.Transactional
?
Solution
Did you look at the javadoc? This is what I read about javax.jdo.annotations.Transactional
:
Annotation to indicate that a member (field or property) is transactional but not persistent. This corresponds to xml attribute persistence-modifier="transactional" of "field" and "property" elements.
This doesn't seem comparable with the @Transactional
annotation from Spring.
Describes transaction attributes on a method or class.
This annotation type is generally directly comparable to Spring's RuleBasedTransactionAttribute class, and in fact AnnotationTransactionAttributeSource will directly convert the data to the latter class, so that Spring's transaction support code does not have to know about annotations. If no rules are relevant to the exception, it will be treated like DefaultTransactionAttribute (rolling back on runtime exceptions).
So, to answer your questions:
may i know can
javax.jdo.annotations.Transactional
be used on service layer just like spring does? do not need to configure xml files. etc?
No.
can
javax.jdo.annotations.Transactional
be used on service layer independent on whether i using hibernate/jpa/jdo at the dao layer? need to configure any other things beside marking methods with@Transactional
?
No. See above.
any different/limitation between
javax.jdo.annotations.Transactional
andorg.springframework.transaction.annotation.Transactional
?
Yes. One is an apple, the other an orange.