I’m using Postgres and have a transactional method defined as follows:
@Entity
public class SomeEntity {
// …
}
@Transactional(isolation = READ_COMMITED)
public void persistUniqueAndSendEmail() {
SomeEntity e = // …
// Persis the entity to Postgres with a unique constraint that may fail
// Once the entity is persisted send the notification email
}
With READ_COMMITED isolation level is it possible that the unique constraint violation is thrown when the transaction is actually committed, not the actual sql statement is executed?
If so that would mean that the email can be sent, but the relevant changes are not persisted.