Trilobyte wrote:
Thanks jchapman,
I don't really like your solution because it forces me to write a lot more HQL and C#. Are there any other solutions? Otherwise I will stick to my first solution, the one with the dev version of NHibernate which supports the <join> tag.
I would argue that you are taking the wrong approach. I think you are concerning yourself with performance at an all too early stage in the game.
In addition to using HQL you could also have a method on the Person which returned the detail you were interested in. Again this would be read-only, and you would have a simple way to return the data you need once you have a person. If you need the data from somewhere else, return the data in the format you need where you build the object from two parameters (the Person and the Organization).
There are many ways to handle this. Using HQL everywhere won't necessarily be the right way, but it is a tool which is available in addition writing your own methods.
I don't think you want to have a person mapped two different ways. One way as a Person and another way as a PersonContact. You violate the identity principle of the session, which may cause many issues further down the line for you. Instead use objects which are not part of the session!