When using Spring-data it is possible to extend the CrudRepository.
How does this Repositories .delete()
method work "under the hood"?
Also, is this method Transactional
? If this is the case, is there any need to use @Transactional
annotations when using Spring-data
.
e.g is @Transactional
needed here? :
Extending CrudRepository:
public interface PersonRepository extends CrudRepository<Person, Integer> {
}
Using delete method in service class:
@Transactional
public void deletePerson(Person person) {
personRepository.delete(person);
}
Edit: How would @Transactional
work here?
@Transactional
public void deletePersonAndTable(Person person, Table table) {
personRepository.delete(person);
tableRepository.delete(Table);
}