Is the delete not working or not working as how you’d expect? Typically an entity has to be managed before it can be deleted, so a JPA provider (hibernate in your case) will load (the query you see) the entity first, then issue the delete.
If you’re only seeing the query, but no corresponding delete, then some possibilities are:
- there’s nothing to delete, make sure the record is there in the db
- the delete needs to be part of a transaction. I believe the Spring data CRUD ops are transactional by default, if not just make sure whatever is calling
deleteByEmailAddress
is transactional
Note: you can avoid the select when removing an entity using a modifying query delete, example below:
// NOTE: you have return void
@Modifying
@Transactional
@Query(value="delete from Contact c where c.emailAddress = ?1")
void deleteByEmailAddress(String emailAddress)