【发布时间】:2014-04-13 10:04:42
【问题描述】:
最简单的查询出现以下错误:
org.hibernate.hql.internal.ast.QuerySyntaxException: <table_name> is not mapped [<query_string>]
在hibernate.cfg.xml我有财产;
<property name="current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
ThreadLocalSessionContext 位于org.hibernate.context.internal 的Hibernate 4.x-hibernate-core-4.2.6.Final.jar 中。
Hibernate 上的其他一切工作正常。然而, 我无法运行查询。
我错过了什么?
感谢您的帮助。
//==========================
编辑:
<table_name> 被定义为 hibernate.cfg.xml 和 everything 中的一个实体,但 HQL——包括 <table_name> 上的更新都在正常工作,没有错误。
【问题讨论】:
-
您缺少的是错误消息,以及 HQL 从不使用表名和列名,而是始终使用实体名和字段/属性名这一事实。
is not mapepd 意味着 Hibernate 不知道名为 的实体。 docs.jboss.org/hibernate/core/4.3/manual/en-US/html/ch16.html -
为什么不发布实际代码和实际查询?
-
您能否在出现该错误之前向我们提供您尝试执行的查询?
标签: hibernate hql hibernate.cfg.xml