Thursday, July 29, 2010

NHibernate.MappingException: No persister for: XXX

Came across this error yesterday. Although it looks like a problem in my mapping files, it wasn't. Such an error could be caused by one of multiple reasons (at least that is what my googling about it keeps giving). In my case it was something like the following query:

session
.CreateSQLQuery("select whatever from AClass where AProperty = :AParameter")
.SetEntity("AParameter", 1)
.List();

apparently, I used SetEntity where I should have used a simple SetParameter (yes I used copy paste!). My actual exception was

NHibernate.MappingException: No persister for: System.Int32

and such an error could have been caused by any such mistake when setting Binding Parameters for a query.
Hope this helps someone in despair.

kick it on DotNetKicks.com

2 comments:

Anonymous said...

Bloody Brilliant!

Anonymous said...

You need to make it .SetInt32(1) instead of SetEntity()

Post a Comment