java123999
java123999

Reputation: 7394

Making Transactional deletes in Spring Data?

I have an application that is using `Spring data'.

I want to ensure that either both deletions (code below) are carried out, or for a rollback to happen.

How can I ensure that .delete() methods shown below are transactional?

@Service
public class databaseService{

    //some code


  public void deleteRows(){

    carRepository.delete(car);
    personRepository.delete(person);

    }   

}

Upvotes: 1

Views: 66

Answers (1)

Christophe Schutz
Christophe Schutz

Reputation: 613

Take a look at the @Transactional annotation.

Upvotes: 2

Related Questions