user3703592
user3703592

Reputation: 160

Hibernate JTable Synchronisation

I want to synchronise my SQL database using Hibernate and show the entries in JTable. In order to allow for editing the data in JTable, it is necessary to monitor changes made in JTable and update the database using Hibernate.

There are few examples how to achieve this by using a CustomTableModel. My question is whether you would suggest immediate updates, i.e. db queries after Table edit or collecting multiple changes and commit them together, however this would require to LOCK the db table to avoid parallel changes by other users.

Thanks your answers.

Upvotes: 1

Views: 115

Answers (1)

Gimby
Gimby

Reputation: 5274

Its hard to give a black & white answer to this as it is very much up to many factors. It depends on the data, it depends on the application, it depends on the situation.

I think the middle ground here is to utilize optimistic locking. With what little context you provide, I'd say that is the most fitting.

http://docs.jboss.org/hibernate/orm/4.0/devguide/en-US/html/ch05.html

This implies that if two users do try to alter the same data at the same time, one of them is not going to successfully complete the transaction. But the data is going to be safe.

Upvotes: 2

Related Questions