Results 1 to 3 of 3

Thread: @Transactional precisions

  1. #1
    Join Date
    Jul 2005
    Posts
    21

    Default @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. #2

    Default

    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.

  3. #3
    Join Date
    Jul 2005
    Posts
    21

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •