You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If i try to save detached entity - only FK will be set to null and no DELETE FROM Book statements generated. Book records still orphaned in database.
Oskar Berggren added a comment — 9th October 2013, 17:09:51:
Please show code sample, preferably in the form of a test case.
Fei added a comment — 4th November 2014, 22:21:34:
Any plan to fix this issue?
Alexander Zaytsev added a comment — 24th November 2014, 14:25:22:
<~idiotsky> any plan to provide a test case?
Fei added a comment — 24th November 2014, 15:17:35:
Sorry, I think this case open a year ago, so you should have a test case. I'll make a test case as soon as possible. thank you for your reply.
Fei added a comment — 25th November 2014, 23:40:47:
here is a example, I don't how to upload the whole project here, so I just put a sample code here, any further information please contact me. thank you.
//ContactTest.cs
using System;using System.Collections.Generic;using System.Linq;using NHibernate;using NHibernate.Cfg;using NHibernate.Linq;using NHibernate.Tool.hbm2ddl;using NUnit.Framework;namespaceNH3551{publicclassContact{publicGuidId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicIList<Email> Emails {get;set;}}publicclassEmail{publicGuidId{get;set;}publicstringAddress{get;set;}}[TestFixture]publicclassContactTest{[Test]publicvoidDeleteTest(){varcfg=new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof(Contact).Assembly);new SchemaExport(cfg).Create(false,true);ISessionFactorysessionFactory= cfg.BuildSessionFactory();using(ISessionsession= sessionFactory.OpenSession()){using(ITransactiontransaction= session.BeginTransaction()){varcontact=new Contact
{Id=new Guid("ff9a72f9-3731-4927-ad69-a2ddc719623a"),FirstName="FirstName",LastName="LastName",Emails=newList<Email>{new Email {Address="test@email.com"}}};
session.Save(contact);
transaction.Commit();}}using(ISessionsession= sessionFactory.OpenSession()){using(ITransactiontransaction= session.BeginTransaction()){varcontact=new Contact
{Id=new Guid("ff9a72f9-3731-4927-ad69-a2ddc719623a"),FirstName="FirstName",LastName="LastName",Emails=newList<Email>()};// update detached object
session.Update(contact);
transaction.Commit();}}List<Email>emails;using(ISessionsession= sessionFactory.OpenSession()){using(ITransactiontransaction= session.BeginTransaction()){emails= session.Query<Email>().ToList();}}// After update I expect the email table is empty. actually this is 1 record in the database.
Assert.That(emails, Has.Count.EqualTo(0));}}}
Abby Doris created an issue — 9th October 2013, 16:34:16:
Oskar Berggren added a comment — 9th October 2013, 17:09:51:
Fei added a comment — 4th November 2014, 22:21:34:
Alexander Zaytsev added a comment — 24th November 2014, 14:25:22:
Fei added a comment — 24th November 2014, 15:17:35:
Fei added a comment — 25th November 2014, 23:40:47:
The text was updated successfully, but these errors were encountered: