Announcement Announcement Module
Collapse
No announcement yet.
@Transactional precisions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Transactional precisions

    Hi,

    I enabled @Transactional annotation and it seems that some methods are not transactional (they do not start a transaction). The annotated bean implements an interface (JDK dynamic proxy) and annotated methods are located in the bean (implementation).

    For other beans it works properly but there's a light difference. The methods declared transactional are called internally (not via the interface).

    I was wondering if my usage was write.
    Actually, i used the pattern:

    Code:
    public void create(Item item) {
       try {
          doCreate(Item item);
       }
       catch(RuntimeException e) {
          // log exception
      }
    }
    
    @Transactional
    public void doCreate(Item item) {
    
       ....
    }
    The do<MyMethod>* methods are declared transactional and are called by the <MyMethod> methods which are not transactional. The latters catch any RuntimeExceptions that can occur at commit time and log the exception (and rethrow them as checked exceptions not represented here).

    I noticed that no transaction is started when the doCreate method is invoked from the create method. Can transactions be started from within the implementation bean or are they started only when manipulating the interface ?

    Thanks for your help,
    Luc

  • #2
    Spring AOP does not intercept such 'internal' calls. The reference manual contains a detailed explanation for this in chapter 6.

    There are various possible solutions for this problem.

    Comment


    • #3
      You are right thanks it's explained in paragraph "6.6.1. Understanding AOP proxies"

      Comment

      Working...
      X