Stephan van Hulst wrote:And if two users try to reserve a seat at the same time, it can be solved by performing the reservation (making a change in the database) in a database transaction. If the transaction fails because a seat was already reserved, the user can be notified of this.
Hi, what makes the transaction fail in this case? try to overwrite the PK in db? (But the PK will be different for every transaction when PK is auto-generated.)
How does Hibernate make sure the specific seat already exist in db? (If you say you run a query that checks if the specific seat# with the specific date already exist then still concurrent access of multiple threads may pass this condition.)