更新时间:2023-12-04 09:16:40
您可能可以使用的一种方法是提供一种方法,使您可以从数据库更新" TableModel
,仅包括那些行.发生了变化.
One method you might be able to use is to provide a means by which the you can "update" the TableModel
from the database, including only those rows which have changed.
这将需要您知道插入/更新的行的键"或"id",并仅对这些值运行select
查询.然后,您可以通过某种更新"方法将此ResultSet
传递给先前存在的TableModel
,该方法将简单地加载或更新ResultSet
中的行.
This would require you to know the "key" or "id" of the row(s) inserted/updated and run a select
query only for those values. You would then pass this ResultSet
to the pre-existing TableModel
via some kind of "update" method, which would simply load or update the rows from the ResultSet
.
这可能需要某种Map
,该Map
键入到该行的键"或"id",因此您可以更轻松地对其进行更新.
This may require have some kind of Map
which is keyed to the "key" or "id" of the row, so you can update it more easily.
我可能要考虑的事情之一就是提供行数据的POJO,不仅可以用来存储查找Map
的行,还可以发现指定记录的模型的行索引.
One of things I might consider is providing an POJO of the row data, which you can use to not only store in you look up Map
, but also discover the model's row index for the specified record.