Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have two dao methods and if these two methods are called separately by two different functions. How can i make the dao methods to be transactional(1 transaction two methods) so that if there is any error in second dao method both methods will be rolled back..

share|improve this question

closed as not a real question by gnat, Kilian Foth, GlenH7, Glenn Nelson, Walter Feb 7 at 12:38

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

you wrap them in a service layer.

public interface MyTransactionalService{

  public void doStuff();

}

@Service
@Transactional
class MyTransactionalServiceImpl implements MyTransactionalService{

  @Autowired GenericDaoImpl<ClassOne> classOneDao;
  @Autowired GenericDaoImpl<ClassTwo> classTwoDao;

  // this method will be transactional
  public void doStuff(){
    classOneDao.doThis();
    classTwoDao.doThat();
  }

}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.