Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
igitur opened this issue May 22, 2015 · 3 comments

Comments

@igitur
Copy link

igitur commented May 22, 2015

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 igitur changed the title Throw exception (or do something) when cascading is set on element map Throw exception (or do something) when cascading is set on element map with composite key May 22, 2015
@Beatles1692
Copy link

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?

@igitur
Copy link
Author

igitur commented May 30, 2015

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
Copy link
Author

igitur commented May 30, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants