Not that I know of. But check out this article on inheritance
http://notherdev.blogspot.com/2012/01/mapping-by-code-inheritance.html I've found his articles on NHibernate loquacious mapping invaluable. On Wednesday, May 8, 2013, Drognan wrote: > Forgot to say that I'm using the BeforeMapClassHandler event to map my ids. > > map.Id(x => { > x.Column("Id"); > x.Generator(Generators.Sequence, ...); > }); > > I have many other mappings that works. Difference is that I'm not using > inheritance in any of them. > Have I missed anything? Are there any limitaitions with abstract base > classes deriving from generic ones etc? > > Best Regards > > > On Wednesday, May 8, 2013 9:53:54 AM UTC+2, Drognan wrote: >> >> I'm trying to map the following class structure by code, but failing >> miserabley. I'm using Firebird as my database and NHibernante 3.3.1.400. >> >> public abstract Behaviour : Entity<Long> >> { >> public abstract Product Process(Product product); >> } >> >> public class DiscountBehaviour : Behaviour >> { >> public virtual float Discount{ get; set; } >> public override Product Process(Product product) { /* some logic*/ } >> } >> >> public class NewPriceBehaviour : Behaviour >> { >> public virtual decimal NewPrice { get; set; } >> public override Product Process(Product product) { /* some logic*/ } >> } >> >> >> This is my mapping: >> >> public class BehaviourMap : ClassMapping<Behaviour> >> { >> public BehaviourMap() >> { >> Id(x => x.Id); >> } >> } >> >> public class DiscountBehaviourMap : JoinedSubclassMapping<** >> DiscountBehaviour> >> { >> public DiscountBehaviourMap() >> { >> Key(k => k.Column("`BehaviourId`")); >> Property(x => x.Discount); >> } >> } >> >> public class NewPriceBehaviourMap : JoinedSubclassMapping<** >> NewPriceBehaviour> >> { >> public NewPriceBehaviourMap() >> { >> Key(k => k.Column("`BehaviourId`")); >> Property(x => x.NewPrice); >> } >> } >> >> My database script looks like this: >> >> CREATE TABLE ""Behaviour"" ( >> ""Id"" ""Key"" NOT NULL, >> CONSTRAINT ""PkBehaviour"" PRIMARY KEY (""Id"")); >> >> CREATE TABLE ""DiscountPricingBehaviour"" ( >> ""Id"" ""Key"" NOT NULL, >> ""BehaviourId"" ""Key"" NOT NULL, >> ""Discount"" FLOAT NOT NULL, >> CONSTRAINT ""PkDiscountPricingBehaviour"" PRIMARY KEY (""Id""), >> CONSTRAINT ""FkDPBehaviourBehaviour"" >> FOREIGN KEY (""BehaviourId"") >> REFERENCES ""Behaviour"" (""Id"")); >> >> When trying to commit this transaction I get the following error in >> Firebird: >> >> validation error for column Id, value "*** null ***" >> >> So my question is really... what am I missing here? Is there any >> documentation that might lead me in the right direction, or should I look >> in the code? >> >> Best Regards >> >> -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:_e({}, 'cvml', > 'nhusers%[email protected]');>. > To post to this group, send email to > [email protected]<javascript:_e({}, 'cvml', > '[email protected]');> > . > Visit this group at http://groups.google.com/group/nhusers?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
