In my database, the foreign key column does not allow nulls, but when
NH tries to insert into these tables it is bombing out because it's
trying to insert the child first (with null in the FK col) and come
back and update the FK column after it inserts the parent.
I found an earlier message on this group that briefly discusses this
issue: http://www.mail-archive.com/fluent-n...@googlegroups.com/msg05124.html
Is the only way I can get around this problem still to add the
reference to the parent on the child class?
Thanks,
Kevin Berridge
Try setting inverse on the has many mapping and see if that helps
--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
Thanks,
Kevin
On Dec 29, 2:58 pm, Eric Ridgeway <ang3lf...@gmail.com> wrote:
> Try setting inverse on the has many mapping and see if that helps
>
> On Dec 29, 2009 11:54 AM, "kberridge" <kevin.w.berri...@gmail.com> wrote:
>
> I have a simple parent child relationship where the parent class has a
> collection of children, but the child class doesn't have a reference
> to the parent. I'm mapping it with a HasMany.
>
> In my database, the foreign key column does not allow nulls, but when
> NH tries to insert into these tables it is bombing out because it's
> trying to insert the child first (with null in the FK col) and come
> back and update the FK column after it inserts the parent.
>
> I found an earlier message on this group that briefly discusses this
> issue:http://www.mail-archive.com/fluent-n...@googlegroups.com/msg051...
>
> Is the only way I can get around this problem still to add the
> reference to the parent on the child class?
>
> Thanks,
> Kevin Berridge
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-n...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
Very Important Note: If the <key> column of a <one-to-many> association is declared NOT NULL, NHibernate may cause constraint violations when it creates or updates the association. To prevent this problem, you must use a bidirectional association with the many valued end (the set or bag) marked as inverse="true". See the discussion of bidirectional associations later in this chapter.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
It uses a method called HasManyComponent which doesn't seem to exist
in the current release of Fluent. But this is an old article. Is
there a new way to do this?
As you guessed, I want my child to not exist without a parent. And I
want to be able to cause the child to be inserted by simply adding it
into the Parent's collection, since that most closely represents that
requirement. Am I on the right track here?
Thanks,
Kevin
> > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com><fluent-nhibernate%2Bunsubscr
> > i...@googlegroups.com>
> > > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/fluent-nhibernate?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
> > .
On Dec 29, 2009, at 3:53 PM, kberridge <kevin.w....@gmail.com>
wrote:
>>> %2Bunsubscr i...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/fluent-nhibernate?hl=en.
>>
>> --
>> - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/
>> HudsonAkridge
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Fluent NHibernate" group.
> To post to this group, send email to fluent-n...@googlegroups.com
> .
> To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com
Thanks again,
Kevin
On Dec 29, 6:08 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> You're on the right track. Composite element in a collection should
> work for your needs. I don't recall off the top of my head what the
> fnh syntax is, but look at something like .hasmany().ascompositeelement
> () or something like that. (I'm on my mobile atm otherwise I'd look it
> up for you)
>
> On Dec 29, 2009, at 3:53 PM, kberridge <kevin.w.berri...@gmail.com>
> wrote:
>
>
>
> > I found an article on what you suggest with doing a HasMany() with a
> > composite element:
> >http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/08/15/a-fl...