You can do it, but that doesn't mean you should. In these cases, I like to use a Service (CustomerService
in this case) that has a method call that uses both DAOs. You can define the transaction around the service method, so if one call fails, they both roll back.
The problem with DAOs that call other DAOs is you will quite quickly end up with circular references. Dependency injection becomes much more difficult.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…