Announcement Announcement Module
Collapse
No announcement yet.
@Transactional Annotations -- should they be applied only to Interfaces Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Transactional Annotations -- should they be applied only to Interfaces

    I am trying to use Spring's transactional annotations to manage transactions. My question is: what is the best practice of applying the annotations? I heard someone mentioned that they should be only on the methods in a Java interface, not on methods in class definitions, because @Transactional annotation relies on the AOP mechanism.

    What prompted this question:

    Yesterday, I added @Transactional annotations to methods in a java class definition. All went well, I tested a few, worked fine.

    This morning, when I started my Eclipse, I had 10+ errors in my applicationContext.xml, all pointing to bean definitions (some bean definitions were spared though). The error messages says something like "AOP error: could not find class path for the bean definition". I then commented out all @Transactional annotations, the errors went away. Even after I re-installed those @Transactional, the errors have not re-appeared (that is why I could only provide a prox. error message above). However, this incident did imply to me that Eclipse was not happy with those annotations at sometime.

    I am happy that the errors are gone, but am wonderif I have done right things. Should I add an interface, and annotate only the methods in interface, or it is OK to (@Transactional) annotate methods in class definitions?

    Thanks in advance for your advice

    John
Working...
X