您的位置:首页 > 其它

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

2015-08-07 00:01 330 查看


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

2012-07-31 16:57w103437w2008 | 浏览
522 次 悬赏:25
javax.persistence.EntityNotFoundException: Unable to find com.bfxy.bean.producttype.ProductType with id 0
这个异常怎么回事想不通

id  0什么意思啊

我有更好的答案

分享到:




2条回答

2012-07-31 17:06laistars | 五级 最快回答

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:46itaobao100 | 五级

o其实是一个对象,该方法是按照对象查询的

你传入的类的类型和数据库中你查找的表不匹配
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: