I have to increment the count of an integer column in oracle in spring JPA. So I have written a native query like that
@Modifying
@Transactional
@Query(value = "update sync_transaction_table set sync_status='FINISHED',finished_time=systimestamp ,message_count=message_count+?2 where trx_id=?1", nativeQuery = true)
void updateFinishJob(String trxId, Integer count);
And there and about 10 thread which is calling that method at the same time
totalCount=0;
// some code to count the total
syncTransactionRepo.updateFinishJob(skuConsumerTriggerEvent.getTrxId(), totalCount);
But in last the final value in message_count is not the same as the total value I have counted in all thread. And also every time it is giving me a new number
What mistake I am doing and what is the way to fix it.