简体   繁体   English

NHibernate级联SaveUpdate

[英]NHibernate Cascading SaveUpdate

I'm having problems with saving associations by cascading saveupdate on my entities. 通过在实体上级联saveupdate来保存关联时遇到问题。 I have this mapping override and would like to save it's one-to-many association by cascading, but this doesn't work. 我有此映射替代,并希望通过级联保存它的一对多关联,但这是行不通的。

public class DomainMappingOverride : IAutoMappingOverride<Tcf.Domain.Entities.Domain>
{
    /// <summary>
    /// Overrides the specified mapping.
    /// </summary>
    /// <param name="mapping">The mapping.</param>
    public void Override(AutoMapping<Tcf.Domain.Entities.Domain> mapping)
    {
        mapping.Table("domeinen");
        mapping.Map(m => m.Code, "code_1");
        mapping.Map(m => m.Description, "omschrijving");
        mapping.Map(m => m.Explanation, "toelichting");
        mapping.Map(m => m.CreatedBy, "createdby");
        mapping.Map(m => m.ModifiedBy, "modifiedby");
        mapping.Map(m => m.DateCreated, "createdat");
        mapping.Map(m => m.DateModified, "modifiedat");
        mapping.HasMany<SubDomain>(m => m.SubDomains).KeyColumn("domein").Cascade.SaveUpdate();
    }
}

The object itself is saved, but not the association, what am i doing wrong? 对象本身已保存,但未保存关联,我在做什么错?

I believe that this error message occurs when you try to start a transaction on a session that already has an open transaction. 我相信当您尝试在已具有打开事务的会话上启动事务时,会出现此错误消息。 I would need to know more about your session wrapper to give a better answer. 我需要更多有关您的会话包装的信息,以便提供更好的答案。

The problems was inside my AutoPersistenceModel generation. 问题出在我的AutoPersistenceModel代内部。 My foreign key convention didn't match up. 我的外键约定不匹配。

It was mapping to DomainId, but the column name insinde SQL server is domein. 它映射到DomainId,但是insinde SQL Server中的列名是domein。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM