0

I have a small old application designed for one user. Now software should be changed for multi users. Software is realy simple shows just a one JTable, but data are imported to this table only ones when windows is opened. And the issue is that when one user change some data different user (that works in the same time) do not see this changes because will appears when window will be opened again. And now is me question is in hibernate something like data change litener, that tell to the application tat database data has been changed and you have to update the JTable. I was thinking about @PreUpdate, but I do not know that is the good idea.

  • Try this http://stackoverflow.com/questions/3179136/jtable-how-to-refresh-table-model-after-insert-delete-or-update-the-data – Adamo Sep 08 '15 at 13:17

1 Answers1

1

If you have a number of standalone applications, which all are running in separate JVM and connected to one database (I came to this conclusion because of swing tag), then it's not possible to use Hibernate listeners to deal with it.

In this case, you have to create a separate Thread, that will do database polling in background and update your view, if data changed.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • You have right it is standalone application on separated JVM. It simple aplication but withd large database table, 1500k records is this solution efficient. I was thinking about DatabaseChangeListener on Oracle database. –  Sep 08 '15 at 14:05
  • Yes, it's database specific, so as I didn't know which oneDatabase you use, I didn't said about jdbc listners. As for Oracle, here is some example, how to implement it's DatabaseChangeListener interface http://stackoverflow.com/questions/12618915/how-to-implement-a-db-listener-in-java – Stanislav Sep 08 '15 at 14:10