fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Throw exception (or do something) when cascading is set on element map with composite key

Open igitur opened this issue 10 years ago • 3 comments

Currently, an element map with composite key cannot have cascading set. Refer to https://nhibernate.jira.com/browse/NH-2515

But I keep forgetting that and when I have my mapping as e.g.

  HasMany<double>(v => v.Cashflows)
                .AsMap<DateTime>("CashflowDate")
                .Table("MonthlyLiabilityCashflows")
                .Element("Cashflow")
                .KeyColumns.Add("Scheme_Id", "ValuationDate", "Type")
                .Inverse()
                .Cascade.AllDeleteOrphan() 
                .LazyLoad();

then I keep expecting that it should work. Surely this will confuse other users too. My suggestion is that FNH throw an exception or shows some other kind of warning when the schema builder tries to set the cascade property on an element map.

igitur avatar May 22 '15 08:05 igitur

I am just asking here ,because I am not so familiar with elements (have worked with them recently though) , since elements are (usually) scalar values that there's no matching entity for them , is it possible to have one with non-composite key columns?

Beatles1692 avatar May 30 '15 07:05 Beatles1692

Yes, composite keys work fine with element maps. I'm using it a lot, although it might not be considered the best design, but I specifically wanted to stay clear of surrogate IDs in my case.

It's just cascading that's not supported.

igitur avatar May 30 '15 07:05 igitur

Sorry, I misread your question. Yes, it's very possible to have NON-composite key columns too.

igitur avatar May 30 '15 07:05 igitur