Hi all
I am working on a system using NHibernate 1.2 (ok it's not on the right forum but my queries still do apply I think) where we use the Repository pattern to provide us with CRUD commands to our database.
In terms of layers separation, we've got:
- A services layer which is here to respond to users of the system whether it is a UI or a web service, this layer uses a generic IRepository implementation and some specific ones (like IUserRepository) to perform data manipulation. This layer is obviously as well dependent upon our business layer
- The business layer that contains all our business objects and that includes data + behaviour.
We chose to try to put as much of the business logic inside the business object themselves as possible.
I don't know if this is a wise move because we made an architectural decision that the domain model cannot use the IRepository interface.
On really tricky issue is how I would go to implement the Table Data Gateway in the domain model without compromising our architecture.
For instance, I may have a method on a Person that says that it will relate a Person object to all of the countries starting with the letter "X".
Because, and as I see it, our domain model only works if objects are some form of Active Records.
Person being an domain model representation of one row of the Persons table.
Now my real issue is that with using the IRepository pattern where it's not available to the domain model how would I get access to all (or some using some kind of specification) from a given type ?
Another big issue I've got with not being able to use the IRepository is that how could I implement some business logic where some objects need to be deleted depending on some business rule. Because I don't have the IRepository instance I woudln't be able to do a .Delete(entity) which would ultimately do a ISession.Delete(entity) ??
Many thanks to any pointer!
|