First method is working fine but others has error.
Why am i getting this error. 2 method have same purpose, one of them returns entity, others not.
Help me pls.
**Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.akinon.akipay.processor.entity.PaymentSession#6542]
Object of class [com.akinon.akipay.processor.entity.PaymentSession#6542] optimistic locking failed nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction.
**
@Override
@CacheEvict(cacheNames = CacheConstants.PAYMENT_SESSION_CACHE, key = "#paymentSession.token + #paymentSession.transactionToken", cacheManager = "redisCacheManager")
public PaymentSession updatePaymentSession(PaymentSession paymentSession) {
return repository.save(paymentSession); // NO ERROR
}
@Override
public void updatePaymentSessionStatus(PaymentSession paymentSession, SessionTokenStatus status) {
paymentSession.setStatus(status);
repository.save(paymentSession); // ERROR (OPT. LOCK)
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updatePaymentSessionStatus(PaymentSession paymentSession, SessionTokenStatus status) {
paymentSession.setStatus(status);
repository.save(paymentSession); // ERROR (OPT. LOCK)
}
@Override
public void updatePaymentSessionStatus(PaymentSession paymentSession, SessionTokenStatus status) {
paymentSession.setStatus(status);
repository.saveAndFlush(paymentSession); // ERROR (OPT. LOCK)
}
Used transactional,
used different save method.
Mert Karaman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.