Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-1324

@Transactional annotation at method level doesn't override the one at class level any more

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8.1
    • 1.9.0
    • Data-Module
    • None

    Description

      Hi. The behaviour of @Transactional has changed with 1.8.1:

      Until version 1.8.0 @Transactional annotations at method level overrode those at the class level. Like this:

      @Transactional(readOnly = true)
      public class MyClass {
      
          public void doSomethingReadOnly()
      
          @Transactional
          public void writeSomething()

      This stopped working with version 1.8.1 because the @Transactional annotation at method level seems to be ignored and the transaction for the method remains read-only. The cause is probably the change introduced with DELTASPIKE-940, where the following method was added to org.apache.deltaspike.jpa.impl.transaction.TransactionStrategyHelper:

      EntityManagerMetadata createEntityManagerMetadata(InvocationContext context)
      {
          EntityManagerMetadata metadata = new EntityManagerMetadata();
          metadata.readFrom(context.getMethod(), beanManager);
          metadata.readFrom(context.getMethod().getDeclaringClass(), beanManager);
          return metadata;
      }

      If first reads the data at method level and then at class level, which seems to be the wrong order. Swapping these lines would restore the correct behaviour:

      metadata.readFrom(context.getMethod().getDeclaringClass(), beanManager);
      metadata.readFrom(context.getMethod(), beanManager);

      Attachments

        Activity

          People

            johndament John D. Ament
            jensberke Jens Berke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: