SAP Hybris和ABAP Netweaver裡的DAO(Data access object)

i042416發表於2020-03-14

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進行封裝,以實現上一層對持久層具體實現的解耦。

SAP Hybris和ABAP Netweaver裡的DAO(Data access object)

隨便抽一個ABAP的DAO實現:

SAP Hybris和ABAP Netweaver裡的DAO(Data access object)

Hybris裡所有DAO實現的super class是hybris標準的框架DAO, 定義在如下namespace裡. 討論都是一個DAO作為interface定義操作,

SAP Hybris和ABAP Netweaver裡的DAO(Data access object)

另一個default開頭的DAO提供default實現: 拼SQL然後call flexibile search.

SAP Hybris和ABAP Netweaver裡的DAO(Data access object)

這裡的flexible search就相當於ABAP的OPEN SQL, 把DB的access同具體的DB provider解耦。

runtime時具體用哪個DAO的實現,是在Spring的配置檔案裡注入的:

SAP Hybris和ABAP Netweaver裡的DAO(Data access object)


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2680151/,如需轉載,請註明出處,否則將追究法律責任。

相關文章