Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:1.2.1.400
Mapping documents:
1>Resource.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Sample.Resource, Sample" table="TBL_RESOURCE">
<id name="ResourceId">
<generator class="uuid.hex" />
</id>
<property name="ResourceName" />
</class>
</hibernate-mapping>
2>PageResource.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<joined-subclass name="Sample.PageResource, Sample"
table="TBL_RSR_PAGE" extends="Sample.Resource, Sample">
<key column="ResourceId" />
</joined-subclass>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
//
// I use Spring.Net's NHibernateTemplate to get object as follow:
//
Resource rsr = FindById<Resource>(resourceId);
Full stack trace of any exception that occurs:
Name and version of the database you are using: SqlServer 2005
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
When the code is running, the rsr get a resource from database.
And it's type is "CProxyTypeSampleResource_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2", it's ToString value is "Sample.PageResource".
rsr.GetType().BaseType is typoof(Resource), not the typeof(PageResource).
How can I get the expected type(PageResource) of rsr?
Read this:
http://hibernate.org/42.html