sentiadave wrote:
Can you post your mapping file?
You should have a mapping for S1 and S2, and any collections that reference P should be use the <any> element.
Because P doesn't actually map to a table you can't query "from P". Which rows would you be retrieving?
I think what the original poster is saying is that the values are duplicated between tables. Really what the poster wants is two queries, but does not want to have to type out two queries.
I would recommend writing two separate queries and then merging the results together. This is what NHibernate would do for you anyway. There is no SQL that can be written to return columns of varying types and quantities from two different tables in a single query.
Now, what you state should actually work. See the NHibernate documentation:
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#queryhql-polymorphism. It states that you should be able to query on any object or interface and then it will automatically turn that in to multiple queries. Are you sure your query is written correctly?
That being said maybe it would have been a superior approach to use 3 tables for this mapping. The base table would contain all items which were common to both element (directly mapping the base class) while the two other tables would contain the items specific to the subtypes.