How are models and DAOs supposed to interact? I’m in the process of putting together a simple login module and I’m unsure where to put the “business logic.” If I put the logic with the data in the model, how would I access the logic?
Currently, I have:
- A controller that receives form data
- A model that is a simple reflection of a db table
- A DAO that using hibernate performs a simple select query, based on the
form parameters received by the
controller.
The controller has to find/load the business object matching the request and execute it. The Strategy Pattern is useful in this. The business object on its turn has to get a handle of the DAO and the model to do the process.
E.g. (pseudo, inside a front controller servlet)