Good day , I understand what is a serializable isolation level and how it differs from REPEATABLE READ in Postgres. Serializable transaction is able to detect read write cycles so only the first commit will succeed .
With this in mind, does it make sense to use Hibernate's optimistic locking based on row versioning ? The row versioning will behave in exactly the same manner, if version column was updated then Java exception will be thrown which will rollback the transaction. Moreover, according to Postgres wiki , the trigger has to be created if some updates were done out of application level code (like plain sql query ran by psql). So in my humble opinion , Serializable level is a drop in replacement for Optimistic locking , is it so or there are some use cases where you would prefer Optimistic locking instead ?