我正在尝试执行批量删除对象Feature,它与另一个类FeatureMetadata具有鸟类ManyToOne关系.我抛出了一个SQLGrammerException.
我正在使用的hql:
String hql = "delete from Feature F where F.featuresMetadata.stateGeoId = :stateGeoId";
启用show SQL,生成以下内容:
 delete from FEATURE cross join FEATURESMETADATA featuresme1_ where STATEGEOID=?
直接在db客户端中运行SQL会产生以下异常:
 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cross join FEATURESMETADATA featuresme1_ where stategeoid='01'' at line 1
由于生成的SQL抛出异常,我尝试将方言从MySQL5InnoDBDialect更改为MySQLInnoDBDialect,但没有变化.
有人可以帮忙吗?
JB *_*zet 39
在批量HQL查询中不能指定隐式或显式的连接.子查询可以在where子句中使用,子子查询本身可以包含连接.
所以我觉得这样的事情应该有效:
delete from Feature F where F.id in 
    (select f2.id from Feature f2 where f2.featuresMetadata.stateGeoId = :stateGeoId)
| 归档时间: | 
 | 
| 查看次数: | 6740 次 | 
| 最近记录: |