I use NHibernate and FluenNHibernate.
I have 2 classes Deal and SpecialDeal. Table "SpecialDeal" do not contain Volume column. I really storage and use only 4 properties which are shown in SpecialDealMap. It was OK before I update NHibernate to 4.0 version. Now queries fail because they try to get also Volume from "SpecialDeal" table although Volume is not present in SpecialDealMap and it really is not in "SpecialDeal" table.
How can I fix it?
public class Deal
{
public long Id { get; set; }
public DateTime Time { get; set; }
public decimal Price { get; set; }
public decimal Volume { get; set; }
public Deal() {}
}
public class SpecialDeal: Deal
{
public string Code { get; set; }
}
public class SpecialDealMap: ClassMap<SpecialDeal>
{
Id(x => x.Id);
Map(x => x.Time);
Map(x => x.Price);
Map(x => x.Code);
}
you're going to have to refactor your code. If Volume isn't part of Special Deal then this really isn't an is-a relationship.
I suggest a class layout like
public class Deal
{
public long Id { get; set; }
public DateTime Time { get; set; }
public decimal Price { get; set; }
}
public class VolumeDeal : Deal
{
public decimal Volume { get; set; }
}
public class SpecialDeal : Deal
{
public string Code { get; set; }
}
You've also go to determine whether you want to make a table-per-hierarchy or table-per-subclass. you currently aren't using any of Nhibernate's inheritance mapping because you sub-class doesn't map using the SubclassMap. it's using ClassMap.