How to solve “Batch update returned unexpected row count from update; actual row count: 0; expected: 1” problem?

前端 未结 4 1134
你的背包
你的背包 2021-01-03 18:12

Getting this everytime I attempt to CREATE a particular entity ... just want to know how I should go about figuring out the cause.

I\'m using Fluent NHibernate autom

4条回答
  •  花落未央
    2021-01-03 19:02

    When targeting a view with an INSTEAD OF trigger it can be next to impossible to get the correct row count. After delving a bit into the source I found out that you can make a custom persister which makes NHibernate ignore the count checks.

    public class SingleTableNoResultCheckEntityPersister : SingleTableEntityPersister
    {
        public SingleTableNoResultCheckEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)
            : base(persistentClass, cache, factory, mapping)
        {
            for (int i = 0; i < this.insertResultCheckStyles.Length; i++)
            {
                this.insertResultCheckStyles[i] = ExecuteUpdateResultCheckStyle.None;
            }
    
            for (int i = 0; i < this.updateResultCheckStyles.Length; i++)
            {
                this.updateResultCheckStyles[i] = ExecuteUpdateResultCheckStyle.None;
            }
    
            for (int i = 0; i < this.deleteResultCheckStyles.Length; i++)
            {
                this.deleteResultCheckStyles[i] = ExecuteUpdateResultCheckStyle.None;
            }
        }
    }
    

提交回复
热议问题