Results 1 to 5 of 5

Thread: @Transactional New Transactional propagation

  1. #1
    Join Date
    Dec 2006
    Posts
    108

    Default @Transactional New Transactional propagation

    Hi,

    I use the @Transactional annotation for my transaction management within my application. Not JTA but resource-local and JPA Transaction Manager is my platform transaction manager class

    I am facing a peculiar problem...

    I got a method X() which retrieves a set of records to be processed and within that method I got a method Y() which is to be run in a new transaction context. So here is the source code:

    @Transactional
    public void X(){
    List<Records> rec = manager.getAllRecsForProcessing();

    for(Record a:rec){
    Y(rec);
    }
    }

    @Transactional
    public void Y(Record rec){
    //Do Processing
    }

    When I run this I got each processing of Y() tied to the main transaction started by X(). I want Y to start a new transaction context...Can I run Y() using Propagation.REQUIRES_NEW as from the javadoc it states that this can be run only in a JTA environment ?

    Can someone please point out how to go about a situation like this.

    Thanks in advance

    Rgds...VJ

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    If you are doing this within the same method it won't work.
    http://www.springframework.org/docs/...ng-aop-proxies
    Last edited by karldmoore; Aug 27th, 2007 at 03:07 PM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by karldmoore View Post
    If you are doing this within the same method it won't work.
    http://www.springframework.org/docs/...ng-aop-proxies
    Do you mean the "same object"?

  4. #4
    Join Date
    May 2007
    Posts
    12

    Default

    The methodY() has to have annotation like the following
    Code:
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public methodY() {
    }
    Also this method has to be in a different class as mentioned above.

  5. #5
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by goudh View Post
    The methodY() has to have annotation like the following
    Code:
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public methodY() {
    }
    Also this method has to be in a different class as mentioned above.
    Not exactly. If not Spring proxy-based "AOP," but AspectJ is used, method may reside in the same class.

    Regards,
    Oleksandr

Posting Permissions

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