私はいくつかの奇妙な問題に遭遇しました:
私はテーブルConstrainable
とテーブルを持っていますAttribute
。Attribute
テーブル内で、外部キー制約Constrainable
でAttribute
属するものを指定します。テーブルCASCADE ON DELETE
内のその外部キー制約にを追加しました。Attribute
今、私が削除したい場合、Attribute
これConstrainable
も削除されています..これは起こってはいけませんか、それとも間違っていますか? 私はそうするためにこの方法を使用しています:
public void remove(IDBObject obj) throws DBException {
if (manager != null) {
IDBObject o = null;
try {
o = manager.getReference(obj.getClass(), obj.getPrimaryKey());
} catch (EntityNotFoundException e) {
throw new DBException("Entity doesnt exist");
}
manager.getTransaction().begin();
manager.remove(o);
manager.getTransaction().commit();
return;
}
throw new DBException("Manager is closed or null");
}
この行動の理由は何でしょうか?
DB のより詳細な概要:
Constrainable-Table:
| | ID |
Attribute-Table
:
| | ID | 制約可能な ID | 値 | <--- ここにCASCADE ON DELETE
定義されている