//--Service class--
@Service
public class myService implements myInterface {
@Autowired
private MyDao myDao;
//some code
myDao.updateMethod(/*some arguments*/);
//some code
}
//--Dao class--
@Repository
public class MyDao {
@Transactional(transactionManager = sample_a)
public void updateMethod(/*some arguments*/){
newUpdateMethod(/*some arguments*/);
}
@Transactional(transactionManager = sample_a)
public void newUpdateMethod(/*some arguments*/){
/* Actual call to DB taking place */
}
}
When I call updateMethod from service class it is giving transaction related exception- InvalidDataAccessApiUsageException - No transaction is currently active, Am I using @Transactional
in right way? I also read somewhere @Transactional
should not be used in class with @Repository
annotation, but I have other methods with @Transactional
in Dao class and they are working fine.