铸造对象为布尔引发异常 [英] Casting an object into boolean throwing Exception

查看:106
本文介绍了铸造对象为布尔引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从休眠本地查询得到的数据,这是Object类型来
我需要转换成布尔,我做这样..

I am getting the data from hibernate native query and that is of Object type to which i need to convert into boolean, I am doing this way..

Boolean b = ((java.lang.Boolean) ((Object[]) object)[++i]);

现在我需要将其设置成POJO有一个方法。

Now i need to set it into pojo there is a method as ..

public void setActive(boolean active)
 { this.active = active; }

当我试图进入设置POJO它抛出一个exceptiion

when I am trying to set into pojo it is throwing an exceptiion

 b1.setActive(b);

请告知

推荐答案

使用 b1.setActive(B = NULL b.booleanValue():!?假的)

布尔类具有的booleanValue() methos它返回boolean值。

Boolean class has booleanValue() methos which returns boolean value.

确认对象布尔[]

这篇关于铸造对象为布尔引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆