您的位置:首页 > 移动开发

org.hibernate.hql.ast.QuerySyntaxException: INVOICE is not mapped [from INVOICE]

2016-06-01 14:36 489 查看
使用hibernate的hql语句报错:

org.hibernate.hql.ast.QuerySyntaxException: INVOICE is not mapped [from INVOICE]

原因比较简单,只要在实体类中增加映射注释-实体和表的映射 @Entity(name = "表名")

1有问题的

@Entity
@SuppressWarnings("serial")
@Table(name = "INVOICE")
public class Invoice implements java.io.Serializable {


2正常的

@Entity(name = "INVOICE")
@SuppressWarnings("serial")
@Table(name = "INVOICE")
public class Invoice implements java.io.Serializable {


但是,涉及到多表查询的时候hql查询就无效了,这个时候报这种错误就只能更换为sql语句了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hibernate hql Entity