课程: Learning JDBC

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

The Data Access Object (DAO) pattern

The Data Access Object (DAO) pattern

课程: Learning JDBC

The Data Access Object (DAO) pattern

- [Narrator] One of the oldest patterns in dealing with data access is the DAO pattern. To do data access, there are several objects that you need to start with, especially in either the DAO pattern or the repository pattern. The purpose of this is to provide an abstraction between JDBC and the rest of your code. It can be just abstraction or it can be a true object. It really depends on your use case. I tend to favor the abstraction aspect, but again, that's just a personal preference. Most of the time we will use a DTO with a DAO. The DTOs are nothing more than data transfer objects that are used to store state between the layers. This is very similar to the way that we do a repository pattern. But with DAOs, sometimes people try to combine the DTO and the DAO into a single thing to be more object oriented. That is simply a matter of preference. I do prefer to keep them separate. The whole purpose of doing this is it provides a clear separation of your concerns within your code. By…

内容