my service.Impl class :
@Service
public class HevenServiceImpl implements IHevenService {
/*
*
* Injecting DAO
*/
@Resource
private HevenRepositoryDAO repository;
@Resource
private DecompteRepositoryDAO repository2;
what is the impact ? can we get dirty-read problem !!?
Technically yes you can! But you should follow the single responsibility principle. What it means is, don't let your service layer know about repositories, rather have some manager layer in between(say ServiceManager). ServiceManager will call different set of classes(say RepoManager). Each RepoManager deals with one repository and exposes functions to do all low level sort of things(CRUD operations with transactions management, retry, caching etc can be handled here). Your ServiceManager should deals with multiple RepoManagers and will have the business logic. The Service impl. should just delegate the call to appropriate managers and can do some other stuff like exception handling at single place etc. This means lot of extra classes, which doesn't worth in fairly simple component but adds lot of value as your application/component grows. Use your own judgement to atleast segregate the service layer from repositories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With