You can't have non-nullable on both sides of a cyclic many-to-one
relationship.
That's a RDBMS thing, not just NH.

   Diego


On Tue, Apr 27, 2010 at 17:56, nicklang <[email protected]> wrote:

> Also, here are the Fluent NHibernate mappings:
>
> public class Tester1Map : ClassMap<Tester1>
> {
>    public Tester1Map()
>    {
>        Id(x => x.Tester1Id)
>            .GeneratedBy.GuidComb();
>        Map(x => x.Name);
>        References<Tester2>(x => x.Tester2)
>            .Column("Tester2Id")
>             .Cascade.SaveUpdate()
>             .Not.Nullable();
>    }
> }
>
> public class Tester2Map : ClassMap<Tester2>
> {
>    public Tester2Map()
>    {
>        Id(x => x.Tester2Id)
>            .GeneratedBy.GuidComb();
>        Map(x => x.Name);
>        References<Tester1>(x => x.Tester1)
>            .Column("Tester1Id")
>            .Cascade.SaveUpdate()
>            .Not.Nullable();
>    }
> }
>
> Thanks for any inside you may have!
>
>
> On Apr 27, 4:36 pm, nicklang <[email protected]> wrote:
> > Hi,
> >
> > I have 2 entities, each referencing each other (cyclical dependency)
> > via many-to-one relationships (I'm using FluentNHibernate so they are
> > actually References calls)
> >
> > Now what I'm trying to do is:
> >
> > Tester1 tester1 = new Tester1();
> > tester1.Name = "the tester1";
> >
> > Tester2 tester2 = new Tester2();
> > tester2.Name = "the tester2";
> >
> > tester1.Tester2 = tester2;
> > tester2.Tester1 = tester1;
> >
> > session.Save(tester1);
> >
> > The error I keep getting is on the last line:
> >
> > NHibernate.PropertyValueException: not-null property references a null
> > or transient value DataTransfer.Tester.Tester2.
> >
> > I'm using Guid.Comb for my Ids.
> >
> > I thought NHibernate worked out these details - I'm clearly missing a
> > big piece of the puzzle!
> >
> > Any ideas why this doesn't work?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/nhusers?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to