tags:

views:

306

answers:

1

Hi, I know that this question is repeated one. But no one could answer briefly enough to answer corrctly. I am getting Nhibernate error " No row with given identiifer found error" when im trying to use the guid to give me the record from the table. I am using Nhibernate load function to load the record with the unique identifier(GUID) but if the record is not there it is giving exception. Am I missing some property in hbm.xml file?

+1  A: 

From the documentation,

Note that Load() will throw an unrecoverable exception if there is no matching database row.

If you want to query for a particular record and not have an exception, use an actual query or the Get() method.

Also from the documentation:

If you are not certain that a matching row exists, you should use the Get() method, which hits the database immediately and returns null if there is no matching row.

So use Get() and check the result for null.

Stuart Childs