当前位置: 代码迷 >> J2EE >> hibernate语句出错,该如何处理
  详细解决方案

hibernate语句出错,该如何处理

热度:219   发布时间:2016-04-22 02:31:01.0
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]
  相关解决方案