My problem is that I know one object is type A, but when I try to cast to A, I got a ClassCastException.
I have four classes in my cases: ContentDB, ServerFileSysNode, InnerNode, and SharedFileSysNode. ServerFileSysNode(abstract) InnerNode (concrete subclass of ServerFileSysNode, may have an asscoaited SharedFileSysNode). ...(other subclass of ServerFileSysNode is omitted here ). ShareFileSysNode always associated with a ServerFileSysNode ContentDB( a list of ServerFileSysNode, a list of SharedFileSysNode). Their mapping are shown at the bottom. In my application initialization, I loaded all the ServerFileSysNode and ShareFileSysNode in the ContentDB. However I found that if an InnerNode does not have an associated SharedFileSysNode, the InnerNode will have a type of "InnerNode", that is correct. Otherwise, it will have a type of "ServerFileSysNode$$EnhancedByCGLIB$$00", and the "ServerFileSysNode$$EnhancedByCGLIB$$00" can not cast back to "InnerNode". I just wonder how the hibernate decides that the object should be "ServerFileSysNode$$EnhancedByCGLIB$$00". Since ServerFileSysNode is an abstract clas. In my database, there is no instance which is object of "ServerFileSysNode" Also I did not use the Session.load(Class, id) method to load the object explicitly. All the objects are loaded by association with the ContentDB. Help is appreciated. <?xml version="1.0" encoding="UTF-8"?> <hibernate-mapping> <!-- map for ContentDB --> <class name="ContentDB" table="deviceDB" proxy="contentDB"> <id name="id" column="dbID" type="long" unsaved-value="0"> <generator class="sequence"> <param name="sequence">seq_resourceID</param> </generator> </id> <set name="items" table="node" lazy="true" inverse="true"> <key column="dbID"/> <one-to-many class="ServerFileSysNode"/> </set> <set name="sharedFiles" table="sharedFiles" lazy="true" inverse="true" cascade="save-update"> <key column="dbID"/> <one-to-many class="SharedFileSysNode"/> </set> </class> <!-- map for ServerFileSysNode --> <class name="ServerFileSysNode" table="node" discriminator-value='s' proxy="ServerFileSysNode"> <id name="id" column="fileID" type="long" unsaved-value="0"> <generator class="sequence"> <param name="sequence">seq_resourceID</param> </generator> </id> <discriminator column="class" length="1"/> <many-to-one name="database" column="dbId" class="ContentDB" cascade="none"/> <one-to-one name="persistShareProperty" class="SharedFileSysNode"/> <subclass name="InnerNode" discriminator-value="i" proxy="InnerNode"> <!-- map goes here --> </subclass> </class> <!-- map for the ShareFileSysNode --> <class name="SharedFileSysNode" table="sharedFiles" proxy="SharedFileSysNode" > <id name="id" column="fileID" type="long" unsaved-value="0"> <generator class="foreign"> <param name="property">hardNode</param> </generator> </id> <one-to-one name="hardNode" class="ServerFileSysNode" cascade="none" constrained="true"/> <many-to-one name="database" column="dbId" class="ContentDB" cascade="none"/> </class> </hibernate-mapping> __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel