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

  • @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
    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, 04:07 PM.

    Comment


    • #3
      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"?

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment

          Working...
          X