随笔-9  评论-168  文章-266  trackbacks-0
dao.getHibernateSession().createQuery(hql).setParameter("bookid", bookid).setParameter("batch", batch).executeUpdate(); 

(1)String hql="delete from TbProduceplanaccount ppa where ppa.tbBusinessplanaccount.batch=:batch and ppa.tbProduceplanbook.id=:bookid ";
异常:
Hibernate: delete from Tb_ProducePlanAccount, Tb_BusinessplanAccount tbbusiness1_ where batch=? and ProducePlanBook_ID=?
2011-11-17 11:50:16,166 WARN  [JDBCExceptionReporter] SQL Error: 933, SQLState: 42000
2011-11-17 11:50:16,166 ERROR [JDBCExceptionReporter] ORA-00933: SQL 命令未正确结束 

(2)hql="delete from TbProduceplanaccount ppa where ppa in (from TbProduceplanaccount ppa where ppa.tbBusinessplanaccount.batch=:batch and ppa.tbProduceplanbook.id=:bookid)";
执行正常.

总结: hibernate的理解方式与人不同,不能自动生成子查询;更新或删除操作是不允许联表的,必须通过子查询找出数据.
题外语:级联删除是要设置映射的.
posted on 2011-11-17 12:47 紫蝶∏飛揚↗ 阅读(1274) 评论(0)  编辑  收藏 所属分类: Hibernate

只有注册用户登录后才能发表评论。


网站导航: