I usually use transactions through an abstraction layer I've created, but this was a quick and dirty utility to load up some test data, so I just used the raw API without transactions. Apparently a transaction commit takes care of this, but a normal session close doesn't. I even tried setting the flush mode to always, but that didn't work either. It does seem rather odd behavior that a save on an entity would persist only part of the data.
Sent from my iPad On Jun 12, 2010, at 6:12 AM, James Gregory <[email protected]> wrote: > Interesting. Are you using transactions? > > On Fri, Jun 11, 2010 at 10:16 PM, Derek Greer <[email protected]> wrote: > It appears the issue was due to the session not getting flushed. > > > > > On Fri, Jun 11, 2010 at 11:57 AM, Derek Greer <[email protected]> wrote: > I'm seeing an insert for both Parent and Child, but no update to set the > child foreign key value. > > > > On Fri, Jun 11, 2010 at 11:11 AM, James Gregory <[email protected]> > wrote: > What tends to happen in uni-directional relationships is that a record will > be saved with a null foreign-key and then updated with the id value. Is this > not happening for you? or do you have a constraint that's preventing this? > > On Fri, Jun 11, 2010 at 4:55 PM, Derek Greer <[email protected]> wrote: > I've just decided to try out FNH's automapping for the first time on my > current project and have run into what sounds like the exact same issue as > the one described here. I've got a unidirectional one-to-many relationship > between a Parent and Child where my Parent looks something like so: > > public class Parent > { > public virtual int Id { get; set; } > public virtual IEnumerable<Child> Children { get; set; } > } > > and my Child looks like so: > > public class Child > { > public virtual int Id { get; set; } > // other properties (does not reference parent) > } > > I'm also registering the following convention: > > public class HasManyConvention : IHasManyConvention > { > public void Apply(IOneToManyCollectionInstance instance) > { > instance.Key.Column(instance.EntityType.Name + "_Id"); > instance.Cascade.All(); > } > } > > > When creating a new Parent and adding new instances of Child to the Children > collection and then saving, the Parent and Child tables are populated, but > the foreign key column in the Child table is null. An issue mentioned in the > referenced thread was that cascade all wasn't being used, but I've got that > set. What am I missing? > -- > 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. > > -- > 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. > > > -- > 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. > > -- > 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. -- 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.
