我正在使用postgres,并有一个如下定义的事务性方法:
@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
}
使用READ_COMMITED隔离级别,是否有可能在实际提交事务而不是执行实际的SQL语句时抛出唯一约束违规?
如果是这样,这将意味着可以发送邮箱,但相关更改不会持久存在.