我有一个名为 native 的查询,看起来像这样:
@NamedNativeQuery(name = "deleteRecipes", query = "DELETE FROM RECIPE WHERE rcp_acc_identifier IN (?1)")
这些是配方表的重要部分:
Table "public.recipe"
Column | Type | Modifiers
-------------------------+-----------------------------+---------------------------------------------------------
rcp_pf_id_photodata | bigint |
rcp_pf_id_thumbnaildata | bigint |
Indexes:
"fk_rcp_pf_id_photodata_idx" btree (rcp_pf_id_photodata)
"fk_rcp_pf_id_thumbnaildata_idx" btree (rcp_pf_id_thumbnaildata)
Foreign-key constraints:
"fk_rcp_pf_id_photodata" FOREIGN KEY (rcp_pf_id_photodata) REFERENCES persistable_file(pf_id) ON DELETE CASCADE
"fk_rcp_pf_id_thumbnaildata" FOREIGN KEY (rcp_pf_id_thumbnaildata) REFERENCES persistable_file(pf_id) ON DELETE CASCADE
当我执行上面的查询时,配方将被删除,但不会删除persistable_file中的数据。为什么会这样呢? 附加信息:创建数据库时,我没有设置ON DELETE CASCADE。稍后,我首先从上方删除了两个约束,然后通过附加的ON DELETE CASCADE指令再次添加了约束。这可能是为什么不删除数据的问题吗?