Posts

Showing posts from November, 2017

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance

Ok, this exception "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance" can happen with NHibernate if you have an entity with a list of other entities with the .Cascade.AllDeleteOrphan() mapping. If you clear the list by assigning it a new List<entity>(), this exception will appear. Instead clear the list by using the .Clear() method. Error Code using( var session = _sessionManager.GetSession())         using (var transaction = session.BeginTransaction())         {             var order = repository.GetOrderEagerlyByOrderId(session, fromDb.Id);             var now = DateTime.Now;             const string user = "GNB\\Username";             var future = now.AddYears(1);             var taxType = new TaxType(0, "Code", "AlternateNameE", "AlternateNameF", "NameE", "NameF", "DescriptionE", "DescriptionF", 13, now, fu