开发者

Nhibernate multiple levels hierarchy mapped as joined subclasses fails to work with base class property

开发者 https://www.devze.com 2023-03-23 15:13 出处:网络
I have following hierarchy: ClassA->ClassB->ClassC->ClassD ClassB has PropertyA. All classes are mapped as joined subclasses with table per-class.

I have following hierarchy:

ClassA->ClassB->ClassC->ClassD

ClassB has PropertyA. All classes are mapped as joined subclasses with table per-class.

Mapping is parsed with no errors but I get an error when I try to run a query:

ICriteria crit =session.CreateCriteria(typeof(ClassB));
crit.Add(Expression.Eq("PropertyA", value));
crit.List<ClassB>();

Error is as follows:

NHibernate.QueryException: could not resolve property: PropertyA of: ClassC

I seem to get another related error when persisting instances of ClassD but I'd rather fix this one first.

Why does it happe开发者_高级运维n?


Disregard this. My mapping was not valid - I should use multiple level joined-subclass hierarchy mapping:

<class
 <joined-subclass
  <joined-subclass
...

not linear mapping with extends attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消