Thanks to Anne and Jason for your help. I have tried a few more things
-
1) To test that if this really was a discriminator problem, I tried to
reproduce this error with another hierarchy in my application. I
changed the discriminator column to point to a column which I knew had
bad data. The error I got in that case was:
NHibernate.WrongClassException : Object with id: 41 was not of
the specified subclass: ProductType (Discriminator was: '1')
So, this shows that if NHibernate cannot match the discriminator to an
existing discriminator value, then will throw this error.
2) I ran the log4net logging, and it generated the sql query
perfectly, and binded the correct return values to the correct
columns. Here's the sql query -
SELECT this_.UserID as UserID15_0_,
this_.RoleID as RoleID15_0_
FROM UserRoles this_
WHERE this_.UserID = 979488
I saw that the RoleID (which is the discriminator) came back as '1',
which is correct.
3) I also tried applying the abstract attribute to the Role class.
<class name="Role" table="UserRoles" abstract="true">
This did not help, and I get the same error.
I have tried so many things, read the documentation, searched forums.
But I am ready to try more suggestions that anyone can suggest.
Again, thanks everybody.
- Rohit