I\'ve hit a wall with trying to decouple NHibernate from my services layer. My architecture looks like this:
web -> services -> repositories -> nhiber
abstracting away the ORM will:
and all for very little value: the vague option to exchange the ORM framework which will most probably have a lot of other problems
Update: experience
I was once involved in implementing a new provider of an existing DAL abstraction. It ended up performing badly, introduced a lot of bugs, Errorhandling was a mess and sometimes used stale data because the application assumed the default implementation. Reasons:
It took a lot of refactoring of the application:
Additional points:
Porting (of business tasks) would have been a lot less painfull IMO as we did that for a few because of performance.
Update2: experience2: RoadBlocks while trying to port from NHibernate to EntityFramework (impl with NH but couldn't with EF 4 in reasonable time)
Thank you for the responses! I understand what you are saying, but these answers do not solve my problem. Because of the state of the system I'm writing, I am unable to change my architecture. Instead, I am just going to keep all of my sql/hql/criteria api queries inside of the repository layer instead of trying to expose some sort of a complex query class to my services. This approach should work just fine. For my next architectural approach though, I will consider the points made in the other answers.