views:

145

answers:

0

Say I have abstract base class Animal then Dog and Cat classes. I'm mapping these via table-per-subclass (w/ discriminator). Is it possible to query Animals and also project the discriminator-value or class name?

It seems I cannot project the discriminator column. I know when I list Animals, NHibernate creates the correct Animal type for me. The problem is I want to show this list of Animals in a grid along with the actual animal type. It's further compounded by the fact that I'm transforming the results to a bean so I lose that polymorphism before the list gets to the grid. Do I need to transform to bean manually?

Update: Well apparently I can project the "class" column created by NHibernate. However it's only an int. The int seems to be based on the order the subclasses are defined in the mappings. So I guess I can use that...