Any reason why you are not using a surrogate key?

It think it should however be possible to do like you're trying (use
the 2 references in a composite key). Have you looked at the resulting
mapping?
Also, compare to 
http://devlicio.us/blogs/anne_epstein/archive/2009/11/20/nhibernate-and-composite-keys.aspx

On Jan 14, 10:18 am, Christian Erhardt <[email protected]>
wrote:
> Hello,
>
> I have got a association object with a composite Id to resolve a
> many-to-many association. The .KeyReference() part in the CompositeId()
> leads to alot of selects which nhibernate performs so load the entities.
>
> Now I thought about mapping the columns twice. The id itself for the
> KeyProperty and then adding a Reference for the property. But nhibernate
> throws a "Index out of range exception" because it tries to add a
> parameter to the sql insert command for the two reference properties.
>
> Instead of
>
>           CompositeId()
>              .KeyReference(x => x.Skill, f => f.Type<boSkillBase>(),
> "cat_occu_skill__id")
>              .KeyReference(x => x.Gruppe, f =>
> f.Type<boSkillGruppeBase>(),  "cat_occu_skill_group__id");
>
> to
>
>         CompositeId()
>              .KeyProperty(x => x.SkillId, "cat_occu_skill__id")
>              .KeyProperty(x => x.GruppeId, "cat_occu_skill_group__id");
>
>           References(x => x.Gruppe)
>              .Fetch.Select()
>              .Column("cat_occu_skill_group__id")
>              .Class<boSkillGruppeBase>()
>              .Cascade.None();
>
>           References(x => x.Skill)
>              .Not.LazyLoad()
>              .Fetch.Select()
>              .Column("cat_occu_skill__id")
>              .Class<boSkillBase>()
>              .Cascade.None();
>
> Is there any advice for this? Hm... at second thought this is not really
> a fluent nhibernate question, but maybe someone is kind enough to give
> me an advice?
>
> Regards
>
> Christan Erhardt

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to