0

I'm facing an issue deleting an entity on my SpringBoot project:

On my service I'm calling the following function in order to delete an entity: ecSignatoryService.deleteById(ecSignatoryDTO.getId());. I've verified before, the entity exist in my Database.

EcSignatoryServiceImpl:

    @Override
    @Transactional
    public void deleteById(Long signatoryId) {
        this.ecSignatoryDao.deleteById(signatoryId);
    }

EcSignatoryDaoImpl:

    @Override
    @Transactional
    public void deleteById(Long signatoryId) {
        this.ecSignatoryRepository.deleteById(signatoryId);
    }

And my repository is just an extension of CrudRepository.

I'm probably missing something somewhere but I have no clue.

Thanks

Romain Dereux
  • 119
  • 2
  • 5

1 Answers1

0

This exception usually occurs when you delete an object and then later update it (hope you are not updating the primary key). I have found that using session.clear() after delete usually removes this exception.

Also, if you are using any generator class for id property in hbm mapping file, then do not set the value explicitly.

Many people have had the same error and has shared there experience or solution at Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shubham
  • 549
  • 4
  • 11