could not instantiate class [xxx] from tuple
来源:互联网 发布:淘宝心选在哪里显示 编辑:程序博客网 时间:2024/06/07 05:31
错误代码提示:
org.hibernate.QueryException: could not instantiate class [com.example.cms.model.Attachment] from tuple ... moreCaused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ... moreCaused by: java.lang.NullPointerException ... more
原因分析:
欲查询的对象A中,和对象B关联,在A的一个构造函数中,使用的不是B对象,而是B的id字段,类似如下格式:
public A(field a1, ... ,int bid){ this.a1 = a1; ... this.b.setId(bid);}
此时会出现上述报错,报错的三处caused by翻译过来分别是:
1、没有匹配的构造函数
2、反射对象异常
3、空指针异常
原因出在this.b.setId(bid)身上,由于实例化A的时候,此时A.b还是null,若调用this.b.set方法,就会出现NullPointerException。
修改该处构造方法如下:
public A(field a1, ... ,int bid){ this.a1 = a1; ... B b = new B(); //此处创建一个b对象 this.b.setId(bid);}
问题解决
0 0
- could not instantiate class [xxx] from tuple
- select new com.clsss 报 could not instantiate class from tuple
- Could not instantiate class named NSLayoutConstraint
- 解决Could not instantiate class named NSLayoutConstraint
- ibatis:JavaBeansDataExchange could not instantiate result class
- reason: ‘Could not instantiate class named NSLayoutConstraint’
- Could not instantiate class named NSLayoutConstraint
- Could not instantiate class named NSLayoutConstraint
- 'NSInvalidUnarchiveOperationException' 'Could not instantiate class named 'NSLayoutConstraint'
- Could not instantiate class named NSLayoutConstraint
- Could not instantiate class named NSLayoutConstraint
- NSInvalidUnarchiveOperationException: Could not instantiate class named NSLayoutConstraint
- Could not instantiate class named NSLayoutConstraint
- Could not instantiate class named NSLayoutConstraint
- Could not instantiate class named MKMapView
- Could not instantiate class named IBNSLayoutConstraint
- Could not instantiate class named MKMapView
- Could not find class xxx referenced from method xxx.access$super
- 回顾--使用TabActivity实现底部菜单栏
- MAGENTO调试 打开错误报告的几种方式
- HTTP POST请求报文格式分析与Java实现文件上传
- Android中自定义MultipartEntity实现文件上传以及使用Volley库实现文件上传
- 【华为OJ】【039-无线OSS-高精度整数加法】
- could not instantiate class [xxx] from tuple
- 【华为OJ】【040-输入n个整数,输出其中最小的k个】
- C语言获取随机数
- Android 解决ListView 和 ScrollView 共存冲突的问题
- 在C语言头文件中“”与<>有什么区别?
- C语言函数的递归调用
- 第7周 C语言及程序设计提高例程-25 指针作函数参数
- android 之将自己的自定义组件打包成JAR包
- C语言用递归求斐波那契数,让你发现递归的缺陷和效率瓶颈