JPQL validation errors in named-queries.xml not ignored [message #900117] |
Sat, 04 August 2012 08:00 |
Karsten Wutzke Messages: 124 Registered: July 2009 |
Senior Member |
|
|
Hello,
I have a named-queries.xml file with the following simple query:
<named-query name="IndividualDocument.forTypes">
<query>
SELECT id
FROM IndividualDocument id
JOIN FETCH id.company co
LEFT JOIN FETCH id.documentType dt
WHERE dt IS NULL OR dt IN :docTypes
ORDER BY id.fileName
</query>
</named-query>
There are several errors in the XML editor:
Multiple annotations found at this line:
- The abstract schema type 'co' is unknown.
- The FROM clause has 'IndividualDocument id JOIN FETCH id.company' and 'co LEFT JOIN FETCH
id.documentType' that are not separated by a comma.
- An identification variable must be provider for a range variable declaration.
Multiple annotations found at this line:
- The abstract schema type 'dt' is unknown.
- The FROM clause has 'co LEFT JOIN FETCH id.documentType' and 'dt ' that are not separated by a
comma.
- An identification variable must be provider for a range variable declaration.
Multiple annotations found at this line:
- The identification variable 'dt' is not defined in the FROM clause.
- The IN expression does not have a valid state field path expression or TYPE expession.
- The left parenthesis is missing from the IN expression.
The above query is just an example. The file is full of validation errors:
Everything is working fine with Hibernate as JPA provider, so I assume this one and other queries to be correct. There are no problems with the mappings (code is generated, assume this as working).
Problem is, as suggested here http://www.eclipse.org/forums/index.php/mv/msg/359515/882912/#msg_882912, that I already set all Errors/Warnings in my workspace settings to "Ignore":
However, this doesn't do ANYTHING... I cleaned and re-built the project several times - nothing. Errors still there.
How do you *globally* turn off this whole Dali validation stuff? It would suffice to turn off all JPQL/named-queries.xml validation somewhere.
I even upgraded to the latest Indigo release some minutes ago (full reinstall). Still stuck.
Sorry for the rant, but these problems occurr much too frequently. It makes Dali one of the most annoying (not to say useless) Eclipse tools overall.
Anyway, how do you solve this? I can't do anything useful with the project as long as the errors prevail.
Thanks
Karsten
[Updated on: Sat, 04 August 2012 08:04] Report message to a moderator
|
|
|
Re: JPQL validation errors in named-queries.xml not ignored [message #900173 is a reply to message #900117] |
Sun, 05 August 2012 02:32 |
Karsten Wutzke Messages: 124 Registered: July 2009 |
Senior Member |
|
|
I found the errors. There are 3 error types:
1. the FETCH keyword causes the errors on each JOIN line
2. the parentheses around a collection used as query parameter
3. the plain entity from the FROM clause before an IN ... isn't allowed, you have to use a field from the entity
For 1., this breaks application code - no acceptable workaround.
For 2., using parentheses is invalid JPQL. Please also see this bug https://hibernate.onjira.com/browse/HHH-5126, as it demonstrates it should be used without parentheses (according to the JPA spec). Also look at Also see http://en.wikibooks.org/wiki/Java_Persistence/JPQL_BNF#New_in_JPA_2.0. Note, the 4th example there. No parentheses.
For 3., it appears as if Dali doesn't validate just the entity reference itself before the IN operator, but instead expects a "state field expression". It works when using co.name IN (...) and dt.label IN (...), but the (..) are collections of entities passed (like List<Company> not company names or IDs).
Expecting a field, again looking at http://en.wikibooks.org/wiki/Java_Persistence/JPQL_BNF#New_in_JPA_2.0 doesn't make it clear whether plain entities can be used or not.
Here's the end result:
Currently looks like 3 bugs in one statement... YUCK
Could this be true? At least 1. and 2. are obviously Dali problems.
Can anyone from the developers confirm this pleasE?
Karsten
PS: I have no idea why Dali still shows validation errors on named-queries.xml even when all options are set to "Ignore".
[Updated on: Sun, 05 August 2012 16:58] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04854 seconds