分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

【Hibernate】could not instantiate class.. from tuple] with root cause

发布时间:2023-09-06 02:24责任编辑:顾先生关键词:Hibernateclass

使用hibernate的过程中出现了这个问题,查询语句如下:

1 String hql = "select new GoodsBean(id, name, price, proPic, sales, updatetime, marketReferencePrice) from GoodsBean where bigTypeId = ? order by views desc";2 3 Query query = this.getCurrentSession().createQuery(hql);4 query.setInteger(0, Integer.valueOf(bid));5 query.setFirstResult((p - 1) * pageSize);6 query.setMaxResults(pageSize);7 List<GoodsBean> goodsBeanList = (List<GoodsBean>)query.list();

运行到第七行时出现题目中的错误提示,最后在网上查询资料,说是可能是入参为null,我看了下数据库构造函数中的各参数,果真有一个参数的值为空,赋值后,正常了。

1 new GoodsBean(id, name, price, proPic, sales, updatetime, marketReferencePrice)

参考:https://blog.csdn.net/sunzhemin/article/details/9214435?locationnum=9

【Hibernate】could not instantiate class.. from tuple] with root cause

原文地址:https://www.cnblogs.com/sijizhen/p/10042348.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved