Skip to content
Advertisement

Tag: race-condition

How does Hibernate do row version check for Optimistic Locking before committing the transaction

When before committing the current transaction hibernate checks the version of the row, it should issue an sql select statement for fetching ithe row. Assume that after issuing that select statement hibernate finds out that the row version is not changed, hence it should proceed with committing the transaction. I’m wondering how hibernate can be sure that in time slot

How to guarantee atomic SQL inserts with subqueries?

Given a simplified table structure like this: Can I use a subquery like this for inserting records without causing a race condition? Or are subqueries not atomic? I’m worried about simultaneous INSERTs grabbing the same value for num and then causing a unique constraint violation. Answer Yes, this can most certainly create a race condition, because while all statements are

Advertisement