I am new to concepts like DAO, DAL and Domain Driven Design. In the end I want to decouple the persistence layer (mysql database) from my business objects and logic in a web application. I liked the DAO concept but I got stuck implementing it when I want to create a Business Object from database that has other entities associated with it (represented by foreign key in the db table).
- How are these references (aggregations) handled using DAO pattern? Every online DAO example is simple and shows creation of value-object-like Business Objects only (without referencing other entities or value objects). Is it done using Dependency Injection and if so, where is the dependency created?
- By further reading I guess that Repository pattern from DDD gives the possibility to maybe use DAOs behind the scenes and handle object aggregations. As I understand it, it only provides the so called root (Entity with all references loaded or lazy loaded) to the outer world, what seems a good approach to me. Is Repository recommended when using DAO or can DAOs themselves give this functionality by maintaining Persistence Ignorance to the Business Objects.
I am not using an ORM tool and don't want to as I like to explore these basic patterns directly