i have function in my controller that create a forecast : As you can see i use updateOrCreate methods to add or update a forecast. The problem is when 2 requests from the same user run at the same time (and no forecast is already created) 2 row are inserted. Do you have a solution ? I See that the
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