Thanks for the info, this one has been a bit of a weird issue for a while now. If you want to try sending me the example (to this address) then I'll be grateful, but I can probably knock one together from what you've said.
On Fri, Mar 6, 2009 at 7:42 PM, Roger Heim <roger.h...@gmail.com> wrote: > > Thanks for the info James. Removing the discriminator as an actual > property helped but now I've run into issue #95 (where the > discriminator and the version tag are in the wrong sequence.) I tried > three times to attach an example to the issue that replicates the > problem but each time Google barfed. Briefly, it's dependent on the > order of the DiscriminateSubClassesOnColumn() and Version() in the > ClassMap file. If the sequence is DiscriminateSubClassesOnColumn() > followed by Version(), Fluently.Configure() succeeds but a generated > hbm.xml file is invalid. If the sequence is Version() followed by > DiscriminateSubClassesOnColumn(), Fluently.Configure() failes but a > generated hbm.xml file is correct. > > I'm sorry I don't know enough about the FNH source to offer a patch. > > On Mar 6, 3:44 am, James Gregory <jagregory....@gmail.com> wrote: > > You don't normally have the discriminator as an actual property in your > > entity too, it's usually just a column. That's not to say it's incorrect, > > just something I've not seen before. Perhaps try it without. > > > > On Fri, Mar 6, 2009 at 2:21 AM, Roger Heim <roger.h...@gmail.com> wrote: > > > > > Hi All, > > > > > I've just started using FNH and NHibernate. Between FNH and Steve > > > Bohlen's Summer of NHibernate videos I think I'm starting to get my > > > brain wrapped around this stuff but I have a question about using > > > discriminators and sub-classes. > > > > > I have an entity that implements a General Ledger account. The account > > > can be one of 5 types: Asset, Liability, Equity, Income or Expense and > > > is represented by an Int32 that has the value 1-5. I created a > > > GLAccount class that contains all the properties. The class looks like > > > this: > > > public class GLAccount > > > { > > > public virtual Guid AccountID { get; private set;} > > > public virtual decimal AccountNumber {get; set;} > > > public virtual string Description {get;set;} > > > public virtual int AccountType {get;set;} > > > public virtual int Version {get; private set;} > > > } > > > > > I also created five classes for the different account types: > > > GLAssetAccount, GLLiabilityAccount, GLEquityAccount, GLIncomeAccount > > > and GLExpenseAccount. They are all subclasses of GLAccount but they > > > have no additional properties. Here's the discriminator portion of the > > > mapping class: > > > DiscriminatorSubClassesOnColumn<int>("AccountType"), -1) > > > .SubClass<GLAssetAccount>(1), m=>m.Map > > > (x=>x.AccountType).Not.Nullable()) > > > .SubClass<GLLiabilityAccount>(2), m=>m.Map > > > (x=>x.AccountType).Not.Nullable()) > > > .SubClass<GLEquityAccount>(3), m=>m.Map > > > (x=>x.AccountType).Not.Nullable()) > > > .SubClass<GLIncomeAccount>(4), m=>m.Map > > > (x=>x.AccountType).Not.Nullable()) > > > .SubClass<GLExpenseAccount>(5), m=>m.Map > > > (x=>x.AccountType).Not.Nullable()); > > > > > In my unit test I try to add an instance of the GLAccount object and > > > it passes but it assigns -1 as the AccountType even if I specifically > > > set it; I assume that's because of the -1 in the > > > DiscriminatorSubClassesOnColumn line. But if I try to add an instance > > > of a GLAssetAccount object it fails and throws an > > > IndexOutOfRangeException: Invalid index 4 for this > > > SqlParameterCollection with Count=4 and I never get to see the > > > generated SQL. > > > > > Based on my objects is using Table-Per-Class-Hierarchy correct? Can > > > anyone tell me what I've done wrong? > > > > > Roger Heim > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---