Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top