gpt4 book ai didi

c# - NHibernate:脱水属性时出错 - 这到底是什么?

转载 作者:行者123 更新时间:2023-12-03 02:31:27 29 4
gpt4 key购买 nike

我正在金融系统中进行相当复杂的 NHibernate 交易,创建付款,记录分类帐条目,检查付款是否是发票的总金额,如果是,则将发票标记为已全额付款,等等...很多有趣的东西。当然,它必须在单个事务内发生。

当我尝试将更改提交到 session 时,出现以下错误:

Error dehydrating property value for C3.DataModel.CFAPTransaction.Vendor

谷歌搜索并没有找到很多记录。有人可以告诉我这意味着什么以及我需要在哪里集中调试工作吗?

更新

根据请求,以下是完整的错误消息:

NHibernate.PropertyValueException: Error dehydrating property v  alue for C3.DataModel.CFAPTransaction.Vendor --->

NHibernate.HibernateException: Unable to resolve property: APVendorId at NHibernate.Tuple.Entity.EntityMetamodel.GetPropertyIndex(String propertyName) at NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetPropertyValue(Object entity, String propertyPath) at NHibernate.Persister.Entity.AbstractEntityPersister.GetPropertyValue(Object obj, String propertyName, EntityMode entityMode) at NHibernate.Type.EntityType.GetIdentifier(Object value, ISessionImplementor session) at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand st, Object value, Int32 index, Boolean[] settable, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) --- End of inner exception stack trace --- at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityInsertAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) at NHibernate.Impl.SessionImpl.Flush() at NHibernate.Transaction.AdoTransaction.Commit() at C3.DataModel.Repositories.NHUnitOfWork.Save() in C:\projects\C3\C3.DataModel.Generated\Generated\NHibernateRepositories.generated.cs:line 2659 at C3.WebUI.Areas.Finance.Controllers.AccountsPayableController.CreatePayment(CreatePaymentModel model) in C:\projects\C3\C3.WebUI\Areas\Finance\Controllers\AccountsPayableController.cs:line 434

更新将 NHibernate 置于 DEBUG 模式,我得到了一堆像这样的东西:

processing cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for: C3.DataModel.APVendor cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for collection: C3.DataModel.APVendor.Transactions done cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for collection: C3.DataModel.APVendor.Transactions done processing cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for: C3.DataModel.APVendor NHibernate.Event.Default.AbstractFlushingEventListener ERROR Could not synchronize database state with session NHibernate.PropertyValueException: Error dehydrating property value for C3.DataModel.CFAPTransaction.Vendor ---> NHibernate.HibernateException: Unable to resolve property: APVendorId at NHibernate.Tuple.Entity.EntityMetamodel.GetPropertyIndex(String propertyName) at NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetPropertyValue(Object entity, String propertyPath) at NHibernate.Persister.Entity.AbstractEntityPersister.GetPropertyValue(Object obj, String propertyName, EntityMode entityMode) at NHibernate.Type.EntityType.GetIdentifier(Object value, ISessionImplementor session) at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand st, Object value, Int32 index, Boolean[] settable, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) --- End of inner exception stack trace --- at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityInsertAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) C3.WebUI.Areas.Finance.Controllers.AccountsPayableController ERROR C3.WebUI.Areas.Finance.Controllers.AccountsPayableController: No additional information. NHibernate.PropertyValueException: Error dehydrating property value for C3.DataModel.CFAPTransaction.Vendor ---> NHibernate.HibernateException: Unable to resolve property: APVendorId at NHibernate.Tuple.Entity.EntityMetamodel.GetPropertyIndex(String propertyName) at NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetPropertyValue(Object entity, String propertyPath) at NHibernate.Persister.Entity.AbstractEntityPersister.GetPropertyValue(Object obj, String propertyName, EntityMode entityMode) at NHibernate.Type.EntityType.GetIdentifier(Object value, ISessionImplementor session) at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand st, Object value, Int32 index, Boolean[] settable, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) --- End of inner exception stack trace --- at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityInsertAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) at NHibernate.Impl.SessionImpl.Flush() at NHibernate.Transaction.AdoTransaction.Commit() at C3.DataModel.Repositories.NHUnitOfWork.Save() in C:\projects\C3\C3.DataModel.Generated\Generated\NHibernateRepositories.generated.cs:line 2659 at C3.WebUI.Areas.Finance.Controllers.AccountsPayableController.CreatePayment(CreatePaymentModel model) in C:\projects\C3\C3.WebUI\Areas\Finance\Controllers\AccountsPayableController.cs:line 434

查询数据库时似乎没有发生这种情况。我有一种感觉,我创建一堆对象,将它们关联起来,然后尝试保留它们,这是有问题的,但这只是一个纯粹的猜测。

最佳答案

nhibernate 可能没有显示正确的错误属性,请检查映射文件中的相邻属性,查找数据库中的数据类型与 .net 中的数据类型或属性中的重复列之间关系中的错误...另请检查此链接 Fluent NHibernate - IndexOutOfRange

关于c# - NHibernate:脱水属性时出错 - 这到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10867390/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com