[ 
https://issues.apache.org/jira/browse/OPENJPA-2563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Reijo Tomperi updated OPENJPA-2563:
-----------------------------------
    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. 

  was:
@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. 


> @SqlResultSetMapping with orm.xml causes ArgumentException
> ----------------------------------------------------------
>
>                 Key: OPENJPA-2563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2563
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.3.0
>         Environment: Windows 7, standalone application and JUnit tests.
>            Reporter: Reijo Tomperi
>         Attachments: namedquery_not_found.zip
>
>
> @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. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to