I was hoping someone could confirm my understanding of transaction behaviour in a Spring service.
Firstly, am I correct in believing that When using TransactionManager
, all services which result in persistence to the database must be invoked from within a @Transactional
method in order for the update to persist to the db?
Eg, Given the following class:
class MyService
{
CustomerImporter customerImporter
CustomerDAO customerDAO
public void updateCustomer(Customer customer)
{
customerDAO.update(customer)
}
public List<Customer> importCustomers(String url)
{
customerImporter.importCustomers(url);
}
return customerDAO.getFromURL(url);
}
If updateCustomer
is not @Transactional
, will the method have any effect?
Furthermore, If on CustomerImporter
the method importCustomers()
is marked @Transactional
but MyService is not, will the update be persisted to the database?