I have a chance to introduce NHibernate into my group, using it with some new components that are being added to an outdated application. I am trying to make out a DAO template with NHibernate around me, and I am puzzled by the architectural issue.
In my fictional example, let's say I have a CarDAO and a car:
public interface CarDAO { Car FindById(int id) ...
I need to be able to convert the car to the right drive. Since this will be a very complicated operation, I need to execute a stored procedure. I don't understand where the ConvertToRightHandDrive () method should go.
It makes sense for me to put the method on Car and give it a method call on CarDAO, which will execute the stored procedure. And this is where I do not understand:
- should the car refer to CarDAO and call CarDAO.ConvertToRightHandDrive?
- should there be some kind of CarService level that calls CarDAO.ConvertToRightHandDrive?
- how about injecting CarDAO using the Car method (Car.ConvertToRightHandDrive (carDAO))
- any other option?
Perhaps this is only a religious argument, and people have different opinions about whether the Essence should have a link to its DAO (or any other DAO, for that matter). I searched StackOverflow for a while and saw some discussions on this topic; but I would be interested in the opinions of people in this particular scenario.
source share