nhibernate-cascade

Forcing nHibernate to cascade delete before inserts

I have a parent object which has a one to many relationship with an ISet of child objects. The child objects have a unique constraint (PageNum and ContentID - the foreign key to the parent). <set name="Pages" inverse="true" cascade="all-delete-orphan" access="field.camelcase-underscore"> <key column="ContentId" /> <one-to-many c...

Clarification on NHibernate Event mechanism

i am in the middle of re factoring an application and i've applied an interface on most entities. I want to change the Save/Update behavior of these entities using the Event mechanism of NH2.1.1. As such i'm implementing an NHibernate.Event.ISaveOrUpdateEventListener public class SaveOrUpdate : ISaveOrUpdateEventListener { public v...

NHibernate cascading save

This is trying to insert null into Comment.BlogArticleID. The following GenericADOException appeared: "could not insert: [NHibernate__OneToMany.BO.Comment][SQL: INSERT INTO Comment (Name) VALUES (?); select SCOPE_IDENTITY()]" The following Inner-Exception appeared: "Cannot insert the value NULL into column 'BlogArticleID', table 'Rela...

NHibernate cascade and generated guid ids - why are they not generated for the children on save?

I do the following: var @case = new Case { Name = "test" }; // User is persistent and loaded in the same session User.AddCase(@case); // sets @case.User = User too Session.Update(User); response.CaseId = @case.Id; The cascade on User.Cases is set to All. But @case.Id is not set until the transacti...

NHibernate ManyToMany Relationship Cascading AllDeleteOrphan StackOverflowException

I have two objects that have a ManyToMany relationship with one another through a mapping table. Though, when I try to save it, I get a stack overflow exception. The following is the code for the mappings: //EventMapping.cs HasManyToMany(x => x.Performers).Table("EventPerformer").Inverse().Cascade.AllDeleteOrphan().LazyLoad().ParentKeyC...

Hibernate: Updates all the items of a set - Cascade 'create' not working

Hi All, I am using following data model (changed to make it simpler). Table: STUDENT, TEACHER, BOOKS_ASSOCIATION, BOOKS_DETAILS. Student and Teacher have a column whose forign key is BOOKS_ASSC_ID, hbm mapping as following <many-to-one name="bookAssociation" class="com.example.BookAssociation" not-null="false" fetch="join" cas...

Hibernate: cascade question

In hibernate, there are many information about set cascade to "all, delete" and so on, but I want to know the effect of set cascade to "none" now I have a class Parent, and it's child-class Child, class Parent{ List<Child> childs; ....} and in the file parent.hbm.xml(I omitted other content) <class name="Parent" table="parent" ...

Nhibernate Not Updating Cascade Relation On Win Server 2008

Hi, We are using NHibernate with Fluent mapping to build a WebForms application. In our model, we have a simple References relationship with Cascade.All() set. When we save the entity, NH behaves as expected and 1) saves the referenced entity, 2) updates the parent entity setting the child key. Deploying this same version to our prod...

Fluent NHibernate Joined References Ignoring Cascade Rule

I'm using Fluent NHibernate in an attempt to improve testability and maintainability on a web application that is using a legacy database and I'm having some trouble mapping this structure properly: I have two tables that really represent one entity in the domain, and so I'm using a join to map them as such, and a third table that repre...