Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2226

Automatic runtime enhancement only works when the class is listed in the first persistence-unit

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.1, 2.2.0
    • None
    • jpa
    • None

    Description

      When multiple persistence-units are defined in the persistence.xml, only the first one is examined when looking for classes to enhance when using the automatic runtime enhancement (e.g., using the "-javaagent:openjpa.jar" argument). So if the project uses the following persistence.xml:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
      <persistence-unit name="unit1" transaction-type="RESOURCE_LOCAL">
      <class>unit1.SomeClass</class>
      </persistence-unit>
      <persistence-unit name="unit2" transaction-type="RESOURCE_LOCAL">
      <class>unit2.OtherClass</class>
      </persistence-unit>
      </persistence>

      In this example, when unit1.SomeClass is loaded, it will be enhanced, but unit2.SomeClass won't ever be enhanced.

      The exception we get is following:

      Exception in thread "main" <openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "select t from OtherClass t". Error message: The name "OtherClass" is not a recognized entity or identifier. Perhaps you meant SomeClass, which is a close match. Known entity names: [SomeClass]
      at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:119)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:194)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:167)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:242)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:212)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:205)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$200(JPQLExpressionBuilder.java:80)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:2417)
      at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:61)
      at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:162)
      at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:673)
      at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654)
      at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)
      at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682)
      at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:589)
      at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:997)
      at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:979)
      at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:102)
      at de.meyerwerft.providertest.backend.BackendZugriff.leseMitPU2(BackendZugriff.java:60)
      at TesterMain.main(TesterMain.java:16)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mmeyer Manuel Meyer
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: