开发者

Fluent Hibernate Mapping hitch - passing wrong column name for subclass

I finished following the summer of nhibernate screen casts and am trying to convert it to fluent, just for the sake of knowledge.

I have two classes (very simple)

public class Customer { ... }
public class PreferredCustomer : Customer { ... }

These follow table per sub class strategy and so the fluent mapping is so:

CustomerMap - 
  //nothing related to PreferredCustomer - the spec says not required
public class PreferredCustomerMap : SubclassMap<PreferredCustomer>
{
    Map(x => x.CustomerSince);
    Map(x => x.OrderDiscountRate);
}

Thats it. My test is failing, upon inspection, its complaining that sql cant find column customer_id

this is the sql produced by hibernate:

SELECT  customer0_.CustomerId as CustomerId1_0_, 
   customer0_.Version as Version1_0_, 
   customer0_.Firstname as Firstname1_0_, 
   customer0_.Lastname as Lastname1_0_, 
   customer0_1_.CustomerSince as Customer2_2_0_, 
   customer0_1_.OrderDiscountRate as OrderDis3_2_0_, 
       //here, customer0_1_.customer_id needs to be CustomerID really.
   case when customer0_1_.Customer_id is not null then 1 when customer0_.CustomerId is not null then 0 end as clazz_0_ 
    FROM [Customer] customer0_ left outer join [PreferredCustome开发者_开发知识库r] customer0_1_ on customer0_.CustomerId=customer0_1_.Customerid 
    WHERE customer0_.Customer_Id=1

Its clearly doing that only on PreferredCustomer joined table. Cant find what needs to be done.

Any Ideas please?

edit: how do I read the xml's produced by fluent? that could be a good start.


You need a call to KeyColumn("CustomerID"); in your SubclassMaps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜