Update when doing a select with NH debugging and exception

207 views
Skip to first unread message

guilemsola

unread,
Oct 10, 2013, 6:13:07 AM10/10/13
to nhu...@googlegroups.com
Hi all,

I am debugging an update when performing a select statement. I have found some information regarding this issue due to bad mapping with database alignment, specially with nullables.

BTW I have found that with log4net enabled I get some exceptions not shown otherwise. Is that possible? Is this some kind of mechanism to give more detail issues?

For instance I get a "NHibernate.PropertyValueException: Error dehydrating property value for Company.Businessframework.Domain.FileInfoEntity.Client ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'." that I do not receive if I execute the same without logging.

Here you have a more detailed log http://pastebin.com/KZX96qwr

Best Regards

Ricardo Peres

unread,
Oct 10, 2013, 9:38:45 AM10/10/13
to nhu...@googlegroups.com
Is your string property Company.Businessframework.Domain.FileInfoEntity.Client marked as not-null? If you are getting a DBNull then perhaps it shouldn't not-null.

RP

guilemsola

unread,
Oct 11, 2013, 12:32:00 AM10/11/13
to nhu...@googlegroups.com
You're right Ricardo, NH looks to be complaining about setting a null value to a non nullable object. And in fact client field is null in database.

But client is an entity class therefore is nullable an no explicit nullable condition should be stated, isn't it?

Ricardo Peres

unread,
Oct 11, 2013, 8:16:06 AM10/11/13
to nhu...@googlegroups.com
On the mapping you can say if the property, as far as NHibernate is concerned, should allow null value or not. In mapping by code, this is achieved with NotNullable(false), you can see more here: http://notherdev.blogspot.pt/2012/01/mapping-by-code-property.html.

RP
Reply all
Reply to author
Forward
0 new messages