jpa NamedQuery queryParameter checking when using entity-mapping xml file
Hi there!
Love your product. I have the following issue / question:
Setup:
IntelliJ with JPA 2.0, entityManager, referencing queries.xml as a <mapping-file>, contains <named-query> elements. Jpa Facet seems to be working, can run the query from console, autoComplete for QueryName when creating em.createNamedQuery("someQueryName...") works.
Some Query with a named Parameter, like "select x from Exampe x where x.date = :date"
Situation:
setting query-parameters via query.setParameter("datee",date); does not result in Intellij error: Cannot resolve query parameter 'datee' when using em.createNamedQuery
The Error IS correctly shown when not using NamedQueries (Does not Matter if using @NamedQuery annotation or NamedQueries via XML Mapping File). Also Intellij supports Refactoring (rename) of QueryParams and correctly changes usages in query.setParameter
i would LOVE these features to be available for namedQueries - am i maybe doing something wrong or is this currently not possible?
Please sign in to leave a comment.
Can you provide a sample project to check?
Sure - i created a project based on java ee 6 maven archetype: http://www.andygibson.net/blog/projects/knappsack/ (jee6-minimal-archetype), added JPA facet, added queries.xml via Module Settings -> Facets -> JPA -> orm.xml
My Examples are shown in PersonDao.java. TLDR: NamedQueries do not support query-Parameter name checking query parameter name refactoring. When writing query via em.createQuery, both work.
I think it would be quite cool if this would work with XML / Namedqueries :-)
Intellij: Ultimate 2019.3
Repo: https://gitlab.com/axel.frederik.brand/jpafacetxmlnamedquerysupport
Thanks & Kind Regards
Axel
Thank you! The error highlighting seems to be working fine:
JPA facet configuration:
But rename refactoring indeed does not rename the parameter.
Could you show your JPA facet configuration please? Thanks.
Hey Andrey, thank you very much for helping me - much appreciated! :-)
Indeed, queryParameter for NamedQuery Annotation is working (seemed to fix itself after restart)
Error is still not shown for NamedQuery XML File sadly (see screenshot), which is what we actually use a lot because of the amount of Queries.
Facet Config:
Anything else i can provide you to help? :-)
Thanks!
Thank you! Filled the https://youtrack.jetbrains.com/issue/IDEA-228361 request. Please vote and follow for updates.