I have a web MVC application with domain objects and data mappers. The class methods of the data mappers contain all database querying logic. I'm trying to avoid mirroring any database structure and, therefore, to achieve the maximum flexibility in constructing the sql statements. So, in principle, I'm trying to not make use of any ORM or ActiveRecord structure/pattern AT ALL.
Let me give you an example: Normally, I could have an abstract class AbstractDataMapper
inherited by all specific data mapper classes - like the UserDataMapper
class. And then I could define a findById()
method in AbstractDataMapper
, to fetch a record of a specific table - like users
- by a given id
value, e.g. user id. But this would imply that I'd always fetch a record from a single table, without the possibility to use any left joins to also fetch some other details from some other tables corresponding to the given id
- user id.
So, my question is: Under these conditions - to which I myself obliged to, should I implement an abstract data mapper class, or each data mapper class should contain its own completely "proprietary" implementation of the data-access layer?
I hope I could express my idea clear. Please tell me, if I was somehow unclear or you have any questions.
Thank you very much for your time and patience.
Aucun commentaire:
Enregistrer un commentaire