no message

This commit is contained in:
2024-10-26 17:46:30 +03:00
parent ed37dd2107
commit 56981686e1
2 changed files with 6 additions and 42 deletions

View File

@@ -174,11 +174,11 @@ public abstract class Database {
}
//</editor-fold>
//<editor-fold desc="работа с внешними ключами">
public <O extends DBObject, F extends DBObject> Vector<DBObject> getVectorByFK(O owner, Class<F> fk_class) {
Vector<DBObject> res = new Vector<>();
public <O extends DBObject, F extends DBObject> Vector<F> getVectorByFK(O owner, Class<F> fk_class) {
Vector<F> res = new Vector<>();
try {
for (Object o : tables.get(fk_class).Data.values()) {
if (fk_class.getField(owner.getFKName()).get(o).equals(owner.getPK())) res.add((DBObject) o);
if (fk_class.getField(owner.getFKName()).get(o).equals(owner.getPK())) res.add((F) o);
}
} catch (Exception e) {
Utils_.MainLog.PrintException(e);
@@ -186,7 +186,7 @@ public abstract class Database {
return res;
}
public <F extends DBObject> void DeleteByFK(DBObject master, Class<F> fk_class) throws Exception {
Vector<DBObject> to_delete = getVectorByFK(master, fk_class);
Vector<F> to_delete = getVectorByFK(master, fk_class);
BeginTransaction();
for (DBObject object : to_delete)
Delete(object);
@@ -194,7 +194,7 @@ public abstract class Database {
}
//-----------
public <F extends DBObject> void DropByFK(DBObject master, Class<F> fk_class) throws Exception {
Vector<DBObject> to_drop = getVectorByFK(master, fk_class);
Vector<F> to_drop = getVectorByFK(master, fk_class);
BeginTransaction();
for (DBObject object : to_drop) {
fk_class.getField(master.getFKName()).set(object, master.getEmptyFK());