我试图写一个同时有效地加入和限制的NHibernate标准。我的数据库看起来像这样..。
案例-> CustomerProducts <-客户案例-> CaseStatuses
每个案例都与一个客户产品相关联(许多情况到一个产品)。
每个客户都有许多客户产品(一个客户有多个客户产品)。
另外,每个案件都有一个案件状态(从一个案件到多个案件)。
这已经用XML文件进行了映射,并且用Sets<>在CustomerProduct映射中解决了案例和客户(通过客户产品)之间的许多到多个解析,这意味着CustomerProduct实体具有以下设置:
客户
案例
然后,我创建一个输入为“Case”的标准。我需要申请的标准是..。
这不起作用,NHibernate告诉我它不能解析到CustomerProduct.Customer.CustomerId的映射。
Case具有CustomerProduct对象的属性。
CustomerProduct具有Customer对象的属性。
客户拥有CustomerId的属性。
知道为什么不行吗?
谢谢。
发布于 2010-01-27 16:02:37
我认为您需要为CustomerProduct.Customer创建一个别名:
criteria.CreateAlias("CustomerProduct", "customerProduct");
criteria.CreateAlias("customerProduct.Customer", "customer");
criteria.Add(Restrictions.Eq("customer.CustomerId", customerId));我很惊讶“身份限制”没有化名。下面是一个关于使用条件API执行连接查询的好文章。
https://stackoverflow.com/questions/2148277
复制相似问题