fluent-nhibernate
fluent-nhibernate copied to clipboard
Throw exception (or do something) when cascading is set on element map with composite key
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.
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?
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.
Sorry, I misread your question. Yes, it's very possible to have NON-composite key columns too.