I am new to ORM, and we started developing a new system using NHibernate as the ORM.
I think this question may refer to any ORM and any language/platform.
The Team Leader has said we should use NHibernate only when retrieving our domain data model objects, ie, not to use any of the built in NHibernate selection or aggregations that will retrieve single primitives or a list of primitives.
The reason behind it was that we need to make a distinction between classic ORM and other abilities, so that usual select and select max will use a “classic” DAL project.
I think this is not so good, because we break the data access to two, and what’s wrong using NHibernate abilities which gets checked compile time?
Are there any reasons to making this distinction?
9
You are going to have the most luck using the functionality baked into the ORM. NHibernate is incredibly flexible and knows how many different databases work. Using it will allow your database layer to be easily portable.
I would say to your team leader:
- NHibernate produces optimised queries
- NHibernate does lazy loading
- Will allow portability across various database platforms
- Supports its own, powerful, querying language.
Don’t “worry” about data access code and leave that to the ORM. Focus on your business logic and problem domain.
EDIT: One thing I just thought of is that if you are manually loading objects you’re likely to miss the best features of NHibernate because your objects are going to be detached.