出现org.hibernate.hql.internal.ast.QuerySyntaxException: goodsinfo is not mapped [from goodsinfo错误

突然出现了下面的错误

org.hibernate.hql.internal.ast.QuerySyntaxException: goodsinfo is not mapped [from goodsinfo where gname like '%%']
	org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
	org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
	org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
	org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3270)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3159)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
	org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
	org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
	org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
	org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
	org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
	org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
	org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
	org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:219)
	org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:197)
	org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1736)
	wyf.zrk.DButil.getPageContent(DButil.java:39)
仔细检查后发现其实是hql语句写错了

hql = "from goodsinfo where gname like '%"+key+"%'";
					tp = "select count(*) from Goodsinfo where gname like '%"+key+"%'";
实体类的名字是Goodsinfo.java而错写成了goodsinfo,hql语句中的goodsinfo是数据库中表的名字,应该改为对应实体类的名称。即:

hql = "from Goodsinfo where gname like '%"+key+"%'";
					tp = "select count(*) from Goodsinfo where gname like '%"+key+"%'";

错误解决!


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值