为什么 Hibernate 查询在 IntelliJ 中有编译错误? [英] Why does Hibernate query have compile error in IntelliJ?

查看:28
本文介绍了为什么 Hibernate 查询在 IntelliJ 中有编译错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个休眠代码:

Query q = session.createQuery("from MyTable where status = :status");

它编译并运行良好..

It compiles and works fine..

但在 IntelliJ 中,我报告了此错误:

But in IntelliJ I get this error reported:

无法解析表达式,不能解析符号'MyTable'

Can't resolve expression, Can't resolve symbol 'MyTable'

为什么 IntelliJ 会抱怨??

Why is IntelliJ complaining??

推荐答案

IntelliJ 正在尝试验证字符串本身内的 HQL 查询.为此,它需要配置为了解您的休眠配置,以确保存在 MyTable 的映射(正如您所知,它在运行时执行 - 在执行时!).

IntelliJ is trying to validate your HQL query inside the string itself. To do this it needs to be configured to know about your hibernate configuration to ensure that a mapping exists for MyTable (it does at runtime, as you know - as it executes !).

在 intelliJ 中查看您项目的休眠配置部分.

Check out the hibernate config section in intelliJ for your project.

如果障碍多于帮助,可能有一种方法可以将其关闭.

There is probably a way of turning it off if it is more hindrance than help.

这篇关于为什么 Hibernate 查询在 IntelliJ 中有编译错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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