org.hibernate.hql.internal.ast.QuerySyntaxException: 【tableName】 is not mapped

你要认真检查一下你写的hql语句,一定是对象查询,特别是【tableName】 不要写你要查询的表,而是查询的对象
比如:
public long getTypeCount(Patent patent) {
String hqlString = “select count(*) from Patent as p where p.type =’”+patent.getType()+"’";
Query query = this.getSession().createQuery(hqlString);
long count =0;
count = ((Number)query.uniqueResult()).intValue();
return count;
}

Patent 是一个对象

而数据库的表名是patent 如果写成String hqlString = “select count(*) from patent as p where p.type =’”+patent.getType()+"’";
!!!!!!!切记!!!!!!!!!!!

你可能感兴趣的:(org.hibernate.hql.internal.ast.QuerySyntaxException: 【tableName】 is not mapped)