I am working on a project with a separated Domain Layer and Repository layer, and I want to introduce NHibernate into the Repository Layer. At the moment all the repository code is hand-coded.
I would prefer to introduce NHibernate gradually - i.e. map one domain entity at a time, and convert the repository for that entity to use NHibernate.
However one of the domain entities I want to map: Account has a many to one relationship with one I don't want to map yet as it is very complex - Dealer. I would like to be able to load the Account using NHibernate, which will somehow load the associated Dealer using the existing repositories.
A nice to have is to be able to do an HQL search for Accounts like this:
"from Account where Account.Dealer.Id =:dealerId"
I have come up with several possibilities
Create an IInterceptor and override GetEntity. However I'm not sure if this method was intended for this purpose.
Create an IPropertyAccessor which goes to get the Dealer from the old repositories when setting the Dealer property on the Account. I don't this is was an intended use of IPropertyAccessor.
Create an IUserType
I don't think any of these would allow the search to be done in the way described above.
Any suggestions as to the best way foward?
Thanks for your help.