Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2027

EntityManagerObjectProvider always provides the initial EntityManger proxy created

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.3.5, 5.3.6, 5.4
    • 5.4.1
    • tapestry-jpa
    • None

    Description

      When persistence.xml defines multiple persistence units, classes injecting EntityManager with @PersistenceContext(unitName=value crash because the entities associated with the PU in configuration are not recognised at runtime.

      By placing trace in the code I established that the first EntityManager injected gets injected to all my other service classes even though I use different unitName= annotations.

      The EntityManagerObjectProvider class contains a class variable proxy and works like a singleton always injecting the first EntityManager proxy class created for any later EntityManager injections.

      The following code fixes the issue and is provided as-is, free and without copyright or warranty. This is more like a refactor because I have also replaced some depricated code. As a patch it also works just to remove the proxy class member variable and the if (proxy == null) condition.

      Attachments

        1. TapestryJPATest.zip
          85 kB
          John Coleman

        Issue Links

          Activity

            People

              kaosko Kalle Korhonen
              johncoleman John Coleman
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: