Upsert failing by throwing message Duplicate entry for key 'PRIMARY'

I don’t know your business requirements, nor do I know how Spring interacts with Hibernate when setting an isolation level via the @Transactional annotation. You will have to figure out how to do this yourself. All I can tell you, is that the exceptions might occur due to the effects of repeatable read.

Configuring hibernate.connection.isolation = Connection.TRANSACTION_READ_COMMITTED does not configure the isolation level for “the whole DB” but just the connections used by Hibernate. Like I wrote, I don’t know your app or your business requirements. You should read into the semantics of the isolation levels and understand what it is that you need.

1 Like