I have two different scheduled cron jobs which runs every 15 mins and finishes the job within 60 sec. Both act on the same enity: read then process and then save the entitiy using JpaRepository save method and it is causing below error
org.springframework.orm.ObjectOptimisticLockingFailureException: Object of class [nl.coin.comp.domain.ServiceProvider] with identifier [105]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [nl.coin.comp.domain.ServiceProvider#105]
As a fix i want to avoid the conflict between both jobs. I was thinking to used @Scheduled(fixedelay) different fixed delay for both but they can overlap as well. Please help me with this.