1

I have a Entity Contact which has three joined-subclass (Person, Company, Branch). When I do a select-query on Contact where I should only get the Person's, Companies or Branches, I can do

select from Contact a where a.class = Person

this is working correct in the case of Person and Branch. But because Branch is himself referencing Company (with CompanyId), and when I do now

select from Contact a where a.class = Company

it will replace Company with CompanyId (from the Branch-Entity).

Does someone have an Idea, how I can prevent HQL from replacing the class-value with a real column?

BennoDual
  • 5,865
  • 15
  • 67
  • 153
  • Perhaps you could use a discriminator instead for your project? See [here](http://stackoverflow.com/questions/6887168/using-discriminator-with-fluent-nhibernate) and [here](http://stackoverflow.com/questions/4708969/query-by-discriminator-in-nhibernate). – Handprint Aug 14 '12 at 13:21

1 Answers1

2

Try to use fully qualified name of the class (including the namespace):

select from Contact a where a.class = Your.Namespace.Company

This should help NHibernate to differentiate class name from property name.

Miroslav Popovic
  • 12,100
  • 2
  • 35
  • 47