views:

315

answers:

1

when using spring @Transcational on service layer, I will need to put <annotation driven> on xml file.

  1. 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?

  2. 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?

  3. any different/limitation between javax.jdo.annotations.Transactional and org.springframework.transaction.annotation.Transactional?

+5  A: 

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 and org.springframework.transaction.annotation.Transactional?

Yes. One is an apple, the other an orange.

Pascal Thivent