SQL and QL Inspections

I have two (perhaps related) problems. Given the following statement:

Query query = manager.createNativeQuery( "select POLICY_NAME from QPE_POLICY where ID = :id" );

If I have the "Persistence QL Problems" inspection turned on, POLICY_NAME, QPE_POLICY, and ID are highlighted as errors even thought the SQL is valid and executes correctly.

If I disable the "Persistence QL Problems" inspection, the statement does not seem to get inspected at all. I can change POLICY_NAME, QPE_POLICY, and ID to non-existent column and table names and they are never highlighted as errors.

I have a datasource configured and it includes a table named QPE_POLICY with ID and POLICY_NAME columns.

Should I be able to configure IDEA to inspect both JPA QL and native SQL in the same project?

Should I be able to configure IDEA to inspect native SQL and report unresolved table and column names?

I am running version 11 build IU-111.69.

Thanks in advance for any info.

2 comments
Comment actions Permalink

Hello Chris,

You have JPA-QL injected in all strings passed to createNativeQuery.
I believe there's an error in your Settings/Language Injections.

Make sure you have SQL and not JPA-QL language injected.
You can do this directly from editor via "Un-inject language" intention
action and then "Inject language" intention.
"Edit  fragment" intention will say what language is currently
injected in the string if any.

Persistence inspections and SQL ones are configured separately in
Settings/Inspections. Even if the inspections are disabled names
completion and navigation should work and the green 'injection'
background should be visible inside the string literal.



On 12/8/11 3:36 AM, Chris Britton wrote:

I have two (perhaps related) problems. Given the following statement:

>

Query query = manager.createNativeQuery( "select POLICY_NAME from QPE_POLICY where ID = :id" );

>

If I have the "Persistence QL Problems" inspection turned on, POLICY_NAME, QPE_POLICY, and ID are highlighted as errors even thought the SQL is valid and executes correctly.

>

If I disable the "Persistence QL Problems" inspection, the statement does not seem to get inspected at all. I can change POLICY_NAME, QPE_POLICY, and ID to non-existent column and table names and they are never highlighted as errors.

>

I have a datasource configured and it includes a table named QPE_POLICY with ID and POLICY_NAME columns.

>

Should I be able to configure IDEA to inspect both JPA QL and native SQL in the same project?

>

Should I be able to configure IDEA to inspect native SQL and report unresolved table and column names?

>

I am running version 11 build IU-111.69.

>

Thanks in advance for any info.

>

---
Original message URL: http://devnet.jetbrains.net/message/5445737#5445737



--
Gregory Shrago
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop With Pleasure!"

0
Comment actions Permalink

Thank you very much Gregory. I should have found that.

0

Please sign in to leave a comment.