IntelliJ IDEA 用“无法解析符号"突出显示 @Entity 类名在 JPQL [英] IntelliJ IDEA highlights @Entity class names with "Cannot resolve symbol" in JPQL

查看:35
本文介绍了IntelliJ IDEA 用“无法解析符号"突出显示 @Entity 类名在 JPQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ IDEA 在 JPQL 中以红色突出显示具有无法解析符号"的持久性 @Entity 类名称,这会分散注意力并掩盖实际问题.

IntelliJ IDEA highlights persistent @Entity class names with "Cannot resolve symbol" in red in JPQL which is distracting and buries real issues.

因此,例如,我在我的存储库中声明一个查询:

So, for example, I declare a query in my repository:

private static final String READ_BY_CANDIDATE_KEY = "SELECT cr FROM Entity AS cr left join cr.relationship AS re left join fetch cr.relationship2 WHERE re.candidateKey=:ID";

.. 和Entity"带有下划线,即使Entity"是一个有效的类名,并且有 @Entity 注释.代码实际运行时,没有问题.

.. and "Entity" is underlined, even though "Entity" is a valid class name, and has the @Entity annotation. When the code actually runs, there are no problems.

我想需要进行某种配置才能让 IDE 知道哪些类是有效的?那个配置是​​怎么做的?

I imagine some sort of configuration is required to let the IDE know what classes are valid? How is that configuration done?

更新:我确实有一个 JPA 方面,但它没有看到带注释的类.它似乎需要一个 persistence.xml 或 orm.xml(我的项目没有使用)

Update: I do have a JPA facet, but it doesn't see the annotated classes. It seems to require a persistence.xml or orm.xml (which my project does not use)

推荐答案

您似乎没有在构面配置中选择默认的 JPA 提供程序.根据您使用的提供商,从列表中选择一个.可用选项包括 EclipseLink、Hibernate、OpenJPA、TopLink

Seems like you have not selected the default JPA provider in facet configuration. Depending upon which provider you are using, pick one from the list. Available options are EclipseLink, Hibernate, OpenJPA, TopLink

这篇关于IntelliJ IDEA 用“无法解析符号"突出显示 @Entity 类名在 JPQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆