【发布时间】:2020-02-11 19:05:08
【问题描述】:
我有 2 个由 Appointment 和 Customer 对象组成的 observableArrayLists,我通过这些对象在应用程序窗口中显示2个表视图。它们是从 SQL 数据库中填充的。
我编写了 deleteCustomer 方法来处理 SQL 操作,最后调用以下方法从列表中删除对象:
MainScreenController.customerDisplayList.remove(deletedCustomer);
在删除客户之前,我还执行以下代码以删除与已删除客户相关的所有约会,因为约会表包含一个外键列,该列指向客户表中的主键:
public static void deleteAppointments(int customerId) throws Exception {
DatabaseConnection.makeConnection();
String sqlStatement = "DELETE FROM appointment WHERE customerId = '" + customerId + "'";
Query.makeQuery(sqlStatement);
DatabaseConnection.closeConnection();
}
现在我的问题是如何根据存储在 Appointment 对象中的 customerId 属性删除 observableArrayList 中包含的约会?
感谢大家的时间和耐心!
【问题讨论】:
标签: java