NHibernate: Error dehydrating property - What the heck is this?

前端 未结 6 2075
谎友^
谎友^ 2021-01-17 10:21

I\'m doing a fairly complex NHibernate transaction in a financial system, creating a payment, recording the ledger entries, checking to see if the payment is the total amoun

6条回答
  •  悲&欢浪女
    2021-01-17 10:42

    I encountered the same error. This is my sample mappings:

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

    If I tried to persist/save this on my database by populating only the property intPersonID and making the objPerson null, this will trigger the dehydrating error on all your properties!

    The reason I am just populating intPersonID is to prevent querying on the database to get the objPerson before saving to the database. Unfortunately, it will trigger an error, so I modified my mappings and corrected with this:

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

    Or if I want to prevent querying on the database by getting the whole object, I will just use this mapping instead:

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

    But combining them is not possible.

提交回复
热议问题