日期:2014-05-20  浏览次数:20761 次

hibernate语句出错
from Goodsinloc g,BatchCkGoodsinlcBase b where g.goodsinId=b.id
执行后报java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.kcwms.mengniu.bean.Goodsinloc
求高人指点

------解决方案--------------------
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.kcwms.mengniu.bean.Goodsinloc
这句说不能把Object数组强转成Goodsinloc对象
------解决方案--------------------
取出的是数组。。。你用对象接受的吧。。。不匹配
------解决方案--------------------
from Goodsinloc g,BatchCkGoodsinlcBase b where g.goodsinId=b.id
返回的结果是个list
list里面的元素是new object[]{new Goodsinloc(),new BatchCkGoodsinlcBase()}
所以你要取出结果集中的Goodsinloc
1.改变SQL语句:SELECT g FROM Goodsinloc g,BatchCkGoodsinlcBase b where g.goodsinId=b.id
2.不改变SQL语句:(object[]list.get(0))[0]