Why put a DAO layer over a persistence layer (like JDO or Hibernate)

前端 未结 10 831
梦谈多话
梦谈多话 2021-01-31 09:13

Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But the earliest examples of Java DAOs interacted directly with relational databases -- they were

10条回答
  •  旧时难觅i
    2021-01-31 09:33

    It's actually must simpler than all of these answers make it out to be. These patterns are all about layers. You don't want circular references to you make layers that can only know about things above them. You want your UICode to be able to reference any and all Services, your Service code to be able to reference any and all DAOs.

    1. DAO
    2. Service
    3. UICode

    with the POJOs being passed from top to bottom.

提交回复
热议问题