Spring-data-jpa-duplicate-key-value-violates-unique-constraint

To handle these violations gracefully, developers typically employ one of three strategies:

If you are manually assigning IDs to entities instead of using @GeneratedValue , you may inadvertently try to reuse an ID that is already present in the table. To handle these violations gracefully

In a multi-threaded environment, two processes might check if a value (like an email address) exists at the same time. Both see that it doesn’t, both attempt to insert it, and the second one fails. both attempt to insert it