Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
1.0.2 and 1.2.0.Beta1
I have spend a lot time to trying to figure this out and it is important to get this resolved before I can recommend Nhibernate on our project so Thx much for your help.
I have two concrete sub-classess that implement an Interface.
Both the sub-classess have identical attributes, however they have different associations.
One of the concrete subclass let's say ClassA has a many-to-many association with another class, let's say ClassB.
Therefore ClassB has a property, which is a collection of ClassA. After I reconstitute ClassB from the database and access its property (collection of ClassA objects); What I get back is a collection of nhibernate proxies that can only be cast to the super class Interface.
Nhibernate throws an exception when I try to cast an proxy to ClassA. I need to cast it to ClassA, because ClassA has associations which is not shared by the Interface or other sub-class ClassB.
The exception message I get is -
Unable to cast object of type 'ProxyInterfaceSystemObject_IPerson_INHibernateProxy_ISerializable' to type 'NHibernateQuickStartExample.Professor'.
BTW I have run into this problem while implementing Justin Gehtland's tutorial -
http://www.theserverside.net/tt/article ... NHibernate
For those of you who have implemented this tutorial, restating the problem in terms of the objects in the tutorial - I retrieve "Department" from the database. I access its property that represents a collection of "Professors". However, I can only cast each object in the Professors collection as a "Person" which is an Interface.
I communicated this issue with Justin, he thinks maybe the libraries may have changed since he wrote the article in 2004.