select o from ProductType o where o.parent is null;所搜顶级目录

select o from ProductType o where o.parent is null;所搜顶级目录

2012-07-31 16:57 w103437w2008  |  浏览 522 次   悬赏: 25
javax.persistence.EntityNotFoundException: Unable to find com.bfxy.bean.producttype.ProductType with id 0
这个异常怎么回事想不通
id  0什么意思啊
我有更好的答案

2条回答

2012-07-31 17:06 laistars  | 五级  最快回答
select o from ProductType o where o.parent is null
第一个o是什么,字段名么,对于这个我很费解
追问:
o ProductType 是别名JPA里面的 这没问题 问题是我加上o.parent is null 就报错
追答:
从提示错误上看,应该不是语句的问题,你自己想想吧!我没遇到过这样的问题
追问:
Unable to find com.bfxy.bean.producttype.ProductType with id 0

怎么会出现这样的错呢, 我查的是 id=0拿来的啊
追答:
id=0...?你的id字段是自增字段不,怎么会等于0
追问:
(Query query =em.createQuery("select o from ProductType o where o.parent is null ");执行没问题)
  for(Object ob:query.getResultList()){
} 执行报错
评论  |  0  0
2012-09-26 21:46 itaobao100  | 五级
o其实是一个对象,该方法是按照对象查询的
你传入的类的类型和数据库中你查找的表不匹配
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值