2012-06-03 11 views
18

Wykonuję dość złożoną transakcję NHibernate w systemie finansowym, tworząc płatność, rejestrując wpisy w księdze głównej, sprawdzając, czy płatność jest całkowitą kwotą faktury, jeśli tak, oznaczając fakturę jako zapłaconą w całości, itp. ... mnóstwo fajnych rzeczy. Naturalnie musi się to odbywać w ramach jednej transakcji.NHibernate: Błąd właściwości odwadniających - Co to do cholery jest?

Kiedy próbuję popełnić zmianę do sesji, pojawia się następujący błąd:

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

googlowania to nie pojawić się wiele rekordów. Czy ktoś może mi powiedzieć, co to oznacza i gdzie muszę skupić się na debugowaniu?

UPDATE

Na życzenie, tutaj jest pełny komunikat o błędzie:

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

UPDATE rzucanie NHibernate w trybie debugowania, mam kilka rzeczy tak:

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

Wygląda na to, że nie ma to miejsca, gdy pytanie ying bazy danych. Mam wrażenie, że ma problemy ze mną, tworząc grupę obiektów, odnosząc je, a następnie próbując je utrzymać, ale to czysta domysły.

+0

Jaki jest pełny wyjątek i czy istnieje wyjątek wewnętrzny? –

+0

co z ** Nie można rozwiązać właściwości: APVendorId ** - czy to daje wskazówkę? Czy mapowanie jest nieprawidłowe? 'NHUnitOfWork.Save()' próbuje wypisać do kolumny i szuka właściwości o nazwie APVendorId. –

+0

Nie * wydaje się być błędnym. Poszczególne repozytoria wydają się poprawnie wykonywać i budować. Wygenerowany schemat wydaje się być poprawny. –

Odpowiedz

14

Jest prawdopodobne, że nhibernate nie pokazuje poprawnej właściwości błędu, sprawdź sąsiadujące właściwości w pliku odwzorowania, szuka błędów w związku między typami danych z bazy danych i typami danych z .net lub powtarzanymi kolumnami we właściwościach. również sprawdź ten link: Fluent NHibernate - IndexOutOfRange

+4

To jest najwyraźniej to, co się stało. Miałem literówkę w innej nieruchomości i myślę, że wpłynęło to na tę. Nie miałbym z tym problemu, oprócz tego, że wiadomość była tak odrażająca, tajemnicza. –

+2

To nie jest zagadkowe - wystarczy spojrzeć na wewnętrzny wyjątek w wklejonych informacjach. –

+0

Um ... nie, patrząc na to dzieje się 6 lat później, to wciąż tajemniczy i straszny komunikat o błędzie. –

3

Powinieneś sprawdzić mapowanie CFAPTransaction, Wygląda na to, że chcesz określić jednego Vendora dla każdej transakcji. W takim przypadku twoje mapowanie musi być jak poniżej kodu.

public CFAPTransactionMap() 
{ 
    HasOne(x => x.Vendor).ForeignKey("VendorId").Cascade.All(); 
    ... 
} 
2

W moim przypadku była to brakująca specyfikacja tożsamości na serwerze SQL.

Simple Object:

public class Employee 
{ 
    public virtual int ID { get; set; } 
} 

Mapowanie:

public class EmployeeMap : ClassMapping<Employee> 
{ 
    public EmployeeMap() 
    { 
     Id(x => x.ID, map => { map.Generator(Generators.Identity); map.UnsavedValue(0); }); 
    } 
} 

SQL:

Oto kolumna ID z klucz podstawowy.

ID column with constraint

I tu widać brakującą Identity Specification, która jest przyczyną problemu. Missing Identity Specification

Aby rozwiązać ten problem, należy określić kolumnę ID jako IDENTITY tj

CREATE TABLE EMPLOYEE 
(
    ID int NOT NULL IDENTITY(0, 1) 
); 
+0

Wow, też to przegapiłem, dziękuję! =) –

0

natknąłem się ten sam błąd.To jest moje przykładowe mapowania:

ManyToOne(x => x.objPerson, map => { map.Column("PersonID"); map.NotNullable(false); }); 
Property(x => x.intPersonID, map => map.Column("PersonID")); 

Gdybym starał się utrzymywać/zapisać to na mojej bazy danych przez wypełnianie tylko właściwość intPersonID i dokonywania objPerson NULL, będzie to wywołać błąd odwadniającego na wszystkich swoich właściwości!

Powodem, dla którego właśnie zapełniam jest zapobieganie przeszukiwaniu bazy danych, aby uzyskać objPerson przed zapisaniem w bazie danych. Niestety, będzie to powodować błąd, więc zmodyfikowałem moje mapowania i poprawione z tym:

ManyToOne(x => x.objPerson, map => { map.Column("PersonID"); map.NotNullable(false); }); 

Lub jeśli chcę uniknąć zapytań w bazie danych poprzez uzyskanie całego obiektu, będę po prostu użyć tego mapowania zamiast:

Property(x => x.intPersonID, map => map.Column("PersonID")); 

Ale ich łączenie nie jest możliwe.

Powiązane problemy