【Hibernate】could not instantiate class.. from tuple] with root cause
使用hibernate的过程中出现了这个问题,查询语句如下:
String hql = "select new GoodsBean(id, name, price, proPic, sales, updatetime, marketReferencePrice) from GoodsBean where bigTypeId = ? order by views desc"; Query query = this.getCurrentSession().createQuery(hql);
query.setInteger(0, Integer.valueOf(bid));
query.setFirstResult((p - 1) * pageSize);
query.setMaxResults(pageSize);
List<GoodsBean> goodsBeanList = (List<GoodsBean>)query.list();
运行到第七行时出现题目中的错误提示,最后在网上查询资料,说是可能是入参为null,我看了下数据库构造函数中的各参数,果真有一个参数的值为空,赋值后,正常了。
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的更多相关文章
- 【Hibernate】Hibernate的多表查询
在<[Hibernate]Hibernate的聚类查询.分组查询.排序与时间之差>(点击打开链接)一文中已经讲述过怎样利用HQL语句代替SQL语句.进行聚类查询.分组查询.排序与时间之差的 ...
- 【hibernate】映射继承关系
[hibernate]映射继承关系 转载:https://www.cnblogs.com/yangchongxing/p/10405151.html ========================= ...
- 【hibernate】自定义转换器
[hibernate]自定义转换器 转载:https://www.cnblogs.com/yangchongxing/p/10398255.html 1.转换基本属性 package cn.ycx.s ...
- 【hibernate】存储图片
[hibernate]存储图片 转载: package cn.ycx.study.hibernate.entity; import javax.persistence.Entity; import j ...
- 【hibernate】映射可嵌入式组件
[hibernate]映射可嵌入式组件 转载:https://www.cnblogs.com/yangchongxing/p/10376452.html 可嵌入 Address 类,没有对应的数据表 ...
- 【hibernate】应用程序级别的视图
[hibernate]应用程序级别的视图 转载:https://www.cnblogs.com/yangchongxing/p/10361281.html 在没有数据库修改权限时,像创建视图可以使用 ...
- 【hibernate】重写物理表名和列明
[hibernate]重写物理表名和列明 转载:https://www.cnblogs.com/yangchongxing/p/10357123.html 假设你的数据库命名有这样的需求,表都以 yc ...
- 【hibernate】常用注解
[hibernate]常用注解 转载:https://www.cnblogs.com/yangchongxing/p/10357118.html 目录 ======================== ...
- 【hibernate】hibernate不同版本的命名策略
===================================================hibernate 4命名策略如下================================ ...
随机推荐
- Spring Boot JPA Entity Jackson序列化触发懒加载的解决方案
Spring Jpa这项技术在Spring 开发中经常用到. 今天在做项目用到了Entity的关联懒加载,但是在返回Json的时候,不管关联数据有没有被加载,都会触发数据序列化,而如果关联关系没有被加 ...
- winform,同个程序只允许启动一次
static class Program { [DllImport("User32.dll")] private static extern bool ShowWindowAsyn ...
- 微信小程序手机预览请求不到数据(最后一条不明所以)
本地开发调试小程序时,用手机预览需要有如下设置:1.微信开发者工具中设置:不校验安全域名.web-view 域名.TLS 版本以及 HTTPS 证书.这样在有网络请求的时候,就可以访问本地的服务器了, ...
- OpenCV__cv::Mat::step
step[0]是矩阵中一行元素的字节数 step[1]是矩阵中一个元素的字节数(elemSize) step1 = step / elemSize1,elemSize1是元素的每个通道所占的字节数 s ...
- 查看crontab运行状态
cron服务是linux的内置服务,但它不会开机自动启动.可以用以下命令启动和停止服务: /sbin/service crond start/sbin/service crond stop/sbin/ ...
- Shell命令-文件及内容处理之grep(egrep)、join
文件及内容处理 - grep(egrep).join 1. grep(egrep):文本过滤工具 grep(egrep)命令的功能说明 grep命令是Linux系统中最重要的命令之一,其功能是从文本文 ...
- POJ1094 Sorting It All Out LUOGU 排序
Sorting It All Out Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 40012 Accepted ...
- Eclipse常用设置及快捷键
1. Eclipse常用设置 1.1 代码自动提示 选择菜单:Window -> Preferences -> Java -> Editor -> Content Assist ...
- kotlin电商学习记录,好久没来逛逛了
好久没来,一直做毕业设计,用kotlin写一个基于以图搜图的购物app,现在又赶上实习,内容多,时间少,不过前途光明并由贵人指点.加油 kotlin电商学习记录 技术选型 视图层 kotlin-and ...
- Django Cookie,Session
Cookie Cookie的由来 HTTP协议是无状态的,每次请求都是独立的,对服务器来说,每次的请求都是全新的,上一次的访问是数 据是无法保留到下一次的 某些场景需要状态数据或者中间数据等相关对下一 ...