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

@SqlResultSetMapping with orm.xml causes ArgumentException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.0, 2.3.0
    • None
    • None
    • None
    • Windows 7, standalone application and JUnit tests.

    Description

      @SqlResultSetMapping annotation with named query in orm.xml causes ArgumentException
      "There is no query with the name "AnyNamedQuery" defined for any of the known persistent classes:" if native query is executed before named query.

      • If named query is executed first, there is no error, which gives somekind of indication that the orm.xml file is found and is correctly formed.
      • If named query is specified with annotation, there is no error, but the error can appear in other classes that attempt to use orm.xml file.

      This happens with version 2.0.0 and also with 2.3.0. Other versions have not been tested.

      I attached source code to simplified example.

      • If you execute test class "error" the test will pass and you will see that it throws ArgumentException "There is no query with the name \"AnyNamedQuery\"".
      • If you execute test "noerror" the test will pass and you will see that there is no exception.
      • The only difference between the tests is the execution order of named and native query.
      • There is also annotation commented out in EntityClass-class. If you enable that annotation and remove the named query from orm.xml, the test in "error" class won't throw exception anymore.
      • The results are the same also if you remove the annotation and specify sql-result-set-mapping in orm.xml. The results are also the same if you don't specify the sql-result-set-mapping anywhere and just execute the method entityManager.createNativeQuery(nativeSql, "mappingName"); . After that createNamedQuery() will fail to find the query from orm.xml.

      Attachments

        1. namedquery_not_found.zip
          5 kB
          Reijo Tomperi

        Activity

          People

            Unassigned Unassigned
            dvice Reijo Tomperi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: