SAP Hybris和ABAP Netweaver里的DAO(D
DAO在Hybris里的定义:
A DAO (Data Access Object) is an interface to the storage back end system. DAOs store and retrieve objects. You use DAOs to save, remove, and find models. DAOs are the place to put SQL or FlexibleSearch statements and nowhere else. This is to ensure further decoupling from the underlying storage facility. DAOs interact with services via models and with the database via FlexibleSearch and SQL statements.
确实这是一个common的concept, 就是对持久层的CRUD进行封装,以实现上一层对持久层具体实现的解耦。
随便抽一个ABAP的DAO实现:
Hybris里所有DAO实现的super class是hybris标准的框架DAO, 定义在如下namespace里. 讨论都是一个DAO作为interface定义操作,
另一个default开头的DAO提供default实现: 拼SQL然后call flexibile search.
这里的flexible search就相当于ABAP的OPEN SQL, 把DB的access同具体的DB provider解耦。
runtime时具体用哪个DAO的实现,是在Spring的配置文件里注入的:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":