4
我被要求在项目的业务逻辑模块中创建类的文档。我注意到有关于如何创建类的模式。该模式如下了解服务和DAO层
public class AModel(){
//fields
//getter and setters
}
public class AService(){
public void processA(AModel model){
//creates instance of AModel, assigns values to fields
//calls ADaoService methods
}
}
public class ADaoService(){
//has methods which call ADao methods
//sample
public AModel retrieveById(long id){
log.debug(...);
return (ADao.retrieveById(id));
}
}
public class ADAo(){
//has entityManager and some query
public AModel retrieveById(long id){
return((AModel) entityManager.find(AModel.class, id));
}
}
我不明白的是为什么AService调用ADaoService方法,而不是仅仅调用自ADaoService方法ADAO方法只是打电话ADAO方法。在我看来,ADaoService只是代码的浪费。他们正在使用Hibernate和JBoss服务器。我只是这种类型的体系结构的新手。希望有人能帮助我理解。谢谢。