删除父类同时删除其所在的子类

w915676061 2014-09-24 10:52:08
请教各位大神删除父类同时删除其所在的子类,父类和子类在同一张表里面。
这是拼的hql
for(String id : idArray){
params = new ArrayList<Integer>();
hql=new StringBuffer("delete from CustomerRating where crId in (");
hql.append("select a.crId from (");
hql.append("select crId from CustomerRating where pName in (");
hql.append("select cName from CustomerRating where crId = ? ");
hql.append(")) a ");
hql.append(") or crId = ?");
params.add(Integer.valueOf(id));
params.add(Integer.valueOf(id));
int result = ht.bulkUpdate(hql.toString(), params.toArray());
if(result <1){
return 0;
}
}

这是生成的sql,在数据库里能删除,但在后台就不能了
delete from CUSTOMERRATING where CRId in (
select a.CRId from (
select s.CRId from CUSTOMERRATING s where s.PName in (
select m.CName from CUSTOMERRATING m where m.CRId in (?)
)) a
) or CRId in (?)
...全文
159 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,657

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧