Java---Design Patterns---DAO

Scenarios and Questions

    In Java programs, it is often necessary to persist data and obtain persistent data, but there are many problems in the process of data persistence (such as different data sources, different storage types, different suppliers, and different access methods). etc.), how can I use a unified interface for data persistence operations?

solution:

Understanding of DAOs

        1. DAO actually uses the combined factory mode to solve problems, and does not bring new functions, so what you learn is actually an idea.

        2. DAO theoretically has no limit on the number of layers.

        3. The layers of DAO are theoretically not sequential.

 The essence of the DAO pattern

        One layer shields one change

Code:

Bag:

Effect:

Factory class (just show an entry factory, other sub-factories are similar):


Because there are too many packages, please contact QQ for the specific code: 447441478

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325524917&siteId=291194637