Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1494

Exception when calling a transactional method twice from a non transaction method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • jpa-2.3.0
    • jpa-2.5.0
    • JPA
    • None

    Description

      This issue was reported by Nicolas Dutertry on the karaf user list:
      http://karaf.922171.n3.nabble.com/JPA-and-transaction-issue-in-Karaf-4-0-4-td4045208.html

      He also provided a repository with a demo (which I forked):
      https://github.com/cschneider/test-jpa

      In short TestServiceImpl has a non Transactional method:
      public void delete(String... names) {
      for (String name : names)

      { System.out.println("Deleting " + name); deleteManager.delete(name); }

      }

      It calls DeleteManager
      @Transactional
      public void delete(String lastName)

      { Query query = entityManager.createQuery( "delete from Person where lastName = :lastName"); query.setParameter("lastName", lastName); query.executeUpdate(); }

      If the method TestServiceImpl.delete is called with one name then it works.
      If it is called with two names it fails.

      It is not even necessary to first create the person records to show the error.

      A workaround is to make the method TestServiceImpl.delete also transactional. Then it works.

      I will create a test case in the jpa code and fix the issue.

      Attachments

        Activity

          People

            cschneider Christian Schneider
            cschneider Christian Schneider
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: