Eric: It's mandatory if you want the child to be saved when saving the parent; hence the cascading. It's not mandatory if you save the children yourself.
On Tue, Mar 3, 2009 at 10:39 PM, Eric Liprandi <eric.lipra...@gmail.com>wrote: > > FYI, > > I get the same (mis)behavior on SQL 2005. So I don't believe it's an > issue with the DB back-end. > I did notice that adding .Cascade.All() to the StoreMap class like > that: > HasMany(x => x.Staff) > .Cascade.All() > .Inverse(); > > Though I am new to the whole Fluent NHibernate and Hibernate in > general, I have noticed that the Cascade.All() is pretty much > mendatory if I want to have "child" object be saved... Not sure why. > > Regards, > > Eric. > > On Mar 3, 2:24 pm, fmorriso <fpmorri...@verizon.net> wrote: > > FYI: still not fixed using the latest Fluent NHibernate code (last > > modified Feb 26, 2009). > > > > On Feb 18, 6:48 pm, x97mdr <jeffreycame...@gmail.com> wrote: > > > > > > > > > *bump* > > > > > Just wondering if this issue was ever resolved? > > > > > On Feb 15, 3:30 pm, fmorriso <fpmorri...@verizon.net> wrote: > > > > > > For what it's worth, here's the code for my temporary work-around. > > > > Put it after this line in Program.cs: > > > > > > var joan = new Employee { FirstName = "Joan", LastName = "Pope" }; > > > > > > // added by Fred Morrison because Store objects > > > > don't seem to save the Employee's > > > > // that work in the store. > > > > var employees = new List<Employee>() { daisy, > > > > jack, sue, bill, joan }; > > > > foreach (var employee in employees) > > > > { > > > > session.SaveOrUpdate(employee); > > > > Console.WriteLine(employee.Id); > > > > } > > > > > > On Feb 12, 5:56 pm, James Gregory <jagregory....@gmail.com> wrote: > > > > > > > Somebody else just raised this exact issue today, I'll investigate > asap. > > > > > Thanks. > > > > > > > On Thu, Feb 12, 2009 at 9:20 PM, fmorriso <fpmorri...@verizon.net> > wrote: > > > > > > > > I'm running the Examples.FirstProject using Microsoft SQL Server > 2008 > > > > > > Developer Edition and Visual Studio 2008 SP1, .Net Framework 3.5 > SP1 > > > > > > and it does not generate any INSERT's for the Employee table. > > > > > > > > The narrative for the example indicates that saving a Store > object > > > > > > should auto-generate any necessary Employee INSERT's, but the > output > > > > > > on the console shows only INSERT's for Store, Product and > > > > > > StoreProduct. A SELECT * FROM dbo.[Employee] returns zero rows. > > > > > > > > There aren't very many changes needed to switch the example to > use SQL > > > > > > Server 2008, but perhaps one or more of those changes I made > could > > > > > > have disabled the automatic generation of Employee INSERT > > > > > > statements? I hate to post tons of code, so if somebody could > email > > > > > > me to show me how to upload the code, I'd be glad to share it - > and > > > > > > maybe learn something in the process. > > > > > > > > Here's just a small example of a change I made to allow the > example to > > > > > > use SQL Server 2008. Hopefully, I didn't mess it up too bad: > > > > > > > > /// <summary> > > > > > > /// Sets up the required NHibernate session factory > > > > > > /// </summary> > > > > > > /// <returns>ISessionFactory instance</returns> > > > > > > private static ISessionFactory CreateSessionFactory() > > > > > > { > > > > > > string connString = GetDatabaseConnectionString(); > > > > > > Console.WriteLine(connString); > > > > > > > > // Use Fluent NHibernate instead of an NHibernate XML > > > > > > config file > > > > > > return Fluently.Configure() > > > > > > .Database(MsSqlConfiguration.MsSql2005 > > > > > > .ConnectionString(c => c.Is(connString)) > > > > > > .ShowSql() > > > > > > .DefaultSchema("dbo") > > > > > > ) > > > > > > .Mappings(m => m > > > > > > .FluentMappings.AddFromAssemblyOf<Program>() > > > > > > ) > > > > > > //WARNING: will DROP/CREATE tables > .ExposeConfiguration > > > > > > (BuildSchema) > > > > > > .BuildSessionFactory(); > > > > > > } > > > > > > > > I built the database myself (so I'm a control freak, sue me) > rather > > > > > > than end up with weird PK and FK constraint names. > > > > > > > > The DDL for the Employee table looks like this: > > > > > > > > CREATE TABLE [dbo].[Employee]( > > > > > > [Id] [int] IDENTITY(1,1) NOT NULL, > > > > > > [LastName] [nvarchar](100) NOT NULL, > > > > > > [FirstName] [nvarchar](100) NOT NULL, > > > > > > [Store_id] [int] NULL, > > > > > > CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED > > > > > > ( > > > > > > [Id] ASC > > > > > > )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, > IGNORE_DUP_KEY > > > > > > = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON > [PRIMARY] > > > > > > ) ON [PRIMARY] > > > > > > > > GO > > > > > > > > ALTER TABLE [dbo].[Employee] WITH NOCHECK > > > > > > ADD CONSTRAINT [FK_Employee_Store] FOREIGN KEY([Store_id]) > > > > > > REFERENCES [dbo].[Store] ([Id]) > > > > > > GO > > > > > > > > ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Store] > > > > > > GO > > > > > > > > The DDL for Store looks like this: > > > > > > > > CREATE TABLE [dbo].[Store]( > > > > > > [Id] [int] IDENTITY(1,1) NOT NULL, > > > > > > [Name] [nvarchar](100) NOT NULL, > > > > > > CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED > > > > > > ( > > > > > > [Id] ASC > > > > > > )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, > IGNORE_DUP_KEY > > > > > > = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON > [PRIMARY] > > > > > > ) ON [PRIMARY] > > > > > > > > GO- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---