nhibernate-cascade

Delete Cascade is not working with NHibernate

自作多情 提交于 2019-12-24 12:25:04
问题 I have a table Communication which has a reference to PersonCompany. In the mapping for PersonCompany i have defined a Cascade-Delete for this reference: this.HasMany(x => x.Communications) .AsSet() .KeyColumn("PersonCompanyId") .Fetch.Select() .Inverse() .Cascade.Delete(); But when I now execute the fallowing HQL-Query: var sql = "delete from PersonCompany where Person.Id in (:idList) or Company.Id in (:idList)"; with var query = NHibernateHelper.CurrentSession.CreateQuery(sql); query

nhibernate bidirectional mapping

泄露秘密 提交于 2019-12-11 14:16:47
问题 Given the object model, mapping, and code below, I want to achieve the following: On SAVE of new parent Party objects, I'd like for the parent to persist child PartyNames as well. SO ideally I can just do: var party = new Party(); party.AddPartyName(_developerName) using(var tx = session.BeginTransaction){ _session.Save (party); tx.Commit() } But my understanding from the last question I asked on this is that while this is doable with inverse="false", I really want to define the children set

Many to Many: Delete one side, the relationship entry BUT don't delete the other side

╄→гoц情女王★ 提交于 2019-12-04 17:10:21
问题 I want to delete an user which has many usergroups but those usergroups don't belong exclusivly to this user: other users can also be using this usergroups. And usergroups can exist even if no user references them. I want to map the many-to-many relationship so that if a user is deleted , the relationship is automatically deleted but NOT the usergroup ? I tried Cascade.All as I thought cascades on many-to-many affect the relationship but not the other side. I thought that only Cascade

NHibernate cascading save

落花浮王杯 提交于 2019-12-01 01:03:31
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 'Relationships_Test_OneToMany.dbo.Comment'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated." I need a unidirectional mapping. The answer provided yet is talking about bi-directional mapping. Does NHibernate cascade save works with

NHibernate cascading save

醉酒当歌 提交于 2019-11-30 20:01:42
问题 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 'Relationships_Test_OneToMany.dbo.Comment'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated." I need a unidirectional mapping. The

Forcing NHibernate to cascade delete before inserts

和自甴很熟 提交于 2019-11-30 12:17:51
问题 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 class="DeveloperFusion.Domain.Entities.ContentPage, DeveloperFusion.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </set> The problem I've hit is if