Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » JPQL validation errors in named-queries.xml not ignored
JPQL validation errors in named-queries.xml not ignored [message #900117] Sat, 04 August 2012 08:00 Go to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 112
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:

index.php/fa/11021/0/

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":

index.php/fa/11022/0/

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 Go to previous messageGo to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 112
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:
index.php/fa/11028/0/
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

Re: JPQL validation errors in named-queries.xml not ignored [message #900363 is a reply to message #900173] Mon, 06 August 2012 15:54 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
Karsten,

Sorry you are running into problems with the JPQL validation. We should have some answers for these issues shortly. There is a way to turn off automatic JPA validation in Eclipse. In the workspace preferences or project properties select the Validation tab. Here you can disable JPA Validation in whole, or you can go click the settings button and turn off validation specifically for ORM Mapping files (content type).

Neil
Re: JPQL validation errors in named-queries.xml not ignored [message #900394 is a reply to message #900363] Mon, 06 August 2012 20:38 Go to previous messageGo to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 112
Registered: July 2009
Senior Member
Hello Neil,

thanks for answering. Switching off the validation for XML files works. It would be nice to use Dali validation in the future though.

I'm curious to know about the issues I had, whether this is valid JPA or bugs found.

Karsten
Re: JPQL validation errors in named-queries.xml not ignored [message #900396 is a reply to message #900394] Mon, 06 August 2012 20:39 Go to previous messageGo to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 112
Registered: July 2009
Senior Member
Oh and please don't forget http://www.eclipse.org/forums/index.php/t/369041/
Re: JPQL validation errors in named-queries.xml not ignored [message #900408 is a reply to message #900363] Mon, 06 August 2012 21:40 Go to previous messageGo to next message
Pascal Filion is currently offline Pascal FilionFriend
Messages: 5
Registered: July 2009
Location: Raleigh, NC
Junior Member
1: JOIN FETCH
The JPA spec does not allow a JOIN FETCH to be identified with an identification variable. JPQL validation is based on the platform set in the project properties (project properties->JPA->Platform combo).

If the platform is set to Generic, then JPQL validation will use the JPQL grammar defined in the corresponding spec. I am not sure if Hibernate added JPQL validation support. You might want to double check with them and maybe request for the support. EclipseLink 2.4 added support for identifying a JOIN FETCH and validation will indeed validate it correctly.

2: Incorrect validation for IN expression using an input parameter
This should have been fixed in Indigo SR2 (3.7.2), see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=367593

3: Plain entity from the FROM clause before an IN
The JPA spec does not allow using an identification variable before the IN expression, only a state field path expression or the TYPE expression:

in_expression ::= {state_field_path_expression | type_discriminator} [NOT] IN { ( in_item {, in_item}* ) | (subquery) | collection_valued_input_parameter }

I do not know if Hibernate supports it.
Re: JPQL validation errors in named-queries.xml not ignored [message #900465 is a reply to message #900408] Tue, 07 August 2012 08:17 Go to previous messageGo to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 112
Registered: July 2009
Senior Member
I indeed set all projects to Generic 2.0. I didn't know that this would so much effect on JPQL validation. I will play with the JPA implementation settings tonight.

1. A JOIN FETCH cannot be qualified? Hmmm, this looks like a bug in the JPA spec if you ask me. Very Happy

2. I'll re-check this.

3. Pure disappointment. I had expected to use entity relationships to see if a company is in the set/list of associated companies and the like. Strange.

Thanks for clearing things up a little.
Karsten
Re: JPQL validation errors in named-queries.xml not ignored [message #900581 is a reply to message #900465] Tue, 07 August 2012 16:04 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
Please feel free to provide feedback to the JPA spec committee. The JPA 2.1 spec is in the works - http://java.net/projects/jpa-spec .

Neil
Previous Topic:Status of how users with multiple projects should use dali/persistence.xml and <jar-file >
Next Topic:Metamodel gets regenerated on Windows/Ubuntu
Goto Forum:
  


Current Time: Sat Dec 20 14:22:40 GMT 2014

Powered by FUDForum. Page generated in 0.02411 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software