Devashish Dixit
Devashish Dixit

Reputation: 1193

Java - Web application where same database field gets edited simultaneousty by many users

I am creating a website where a particular field in database is edited simultaneously by many users (assume all the users are making same edit). How can I cope with this? I need only one user to get notified that their edit has successfully done.

Upvotes: 3

Views: 157

Answers (2)

Oleksi
Oleksi

Reputation: 13097

This is a complicated problem with many possible solutions. Essentially you need a way to lock the table or detect concurrent updates. A common technique for doing this is adding version data to your tables. On every update, you then check the version of the data when it was retrieved from the DB originally against the version of the data right now. If they are different, you know that someone else has changed the data during the update process.

Projects like Hibernate can automate some of this for you, so you should consider using this to help implement table versioning.

Upvotes: 2

Jigar Joshi
Jigar Joshi

Reputation: 240870

Use version number in the table, and check for correct version otherwise throws exception and show the user message that Data was updated and show the latest data

Upvotes: 3

Related Questions