"Cannot resolve query" - how to fix for named queries?
Intellij 9 UE does not find my named queries in a JPA context.
Query q = em.createNamedQuery("selectAclEntriesByUser");
will be marked as incorrect with "cannot resolve query". The named query exists and is declared via annotations in the same file.
Is this the expected behaviour or is there a way to get the IDE to resolve named queries?
请先登录再写评论。
Hello Ingo,
Please post here a bit more about your setup.
Module dependencies, location of persistence unit, JPA facets configuration, etc.
Regards,
Gregory Shrago
On 05.05.2010 13:31, Ingo Wiarda wrote:
>
>
>
Hello Gregory, thanks for your reply.
While preparing the following reply, I found that the original error message has vanished and now another warning is present: query.setParameter("foo",foo) will now show a "cannot resolve query parameter" warning.
1. Location of persistence unit:
The persistence unit is located in another module in the same project. It is referenced by Module Settings => JPA => JPA Configuration Descriptor.
2. Module dependencies
3. Abbreviated example of problematic class
Original source code: http://cinnamon.svn.sourceforge.net/viewvc/cinnamon/EntityLib/trunk/src/server/Acl.java?revision=1887&view=markup
The query is resolved then, you can verify this by navigating the reference.
As far as "cannot resolve query parameter" warning is concerned,
please check that the query indeed has parameter named "foo" (there is none in the supplied code).
You may also try completion inside quotes to get the list of available parameters.
On 05.05.2010 18:41, Ingo Wiarda wrote:
>
"foo" was only used as an example - in fact, every case of query.setParameter(paramName) is marked with "cannot resolve query parameter". The queries are working, the parameter names are correct.
Completion inside quotes does not give a list of available parameters.
This is not a critical problem, but as IntelliJ IDEA seems to be able to analyze query.createNamedQuery(...)*, it would be nice if it could also parse query.setParameter(...) correctly.
* the ability to jump to a named query's declaration is quite useful.
Hi Ingo,
It works for me. As Gregory mentions, a very minimal project to reproduce will likely help to track down the problem.
-tt
Hi,
I have put the lib into its own project.
I hope you are able to reproduce the problem, as it seems somewhat erratic - the error messages seem to change with the tide... (the example project shows the "cannot resolve query parameter" problem, but the original project now reports that numerous class files inside the same package cannot be found).
The iml-files seem to be mostly identical.
Thanks for taking the time to answer my questions
Ingo
Attachment(s):
EntityLib001.zip
IntelliJ adding the JPA and it's doing the validation.You can remove that JPA so that these validation errors will not appear.
Go to settings --> modules-->Expand your project and see if any JPA added. If added select that JPA and delete.
This worked for me.