Hi All,
I have this following problem.
When I save , only my superclass gets persisted in DB.
The SubClass did not get persisted.
I am using
Table per subclass strategy.
Hibernate version:3.0.5
Mapping documents:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="eg">
<class name="Cat" table="CATS">
<id name="id" column="uid" type="long">
<generator class="hilo"/>
</id>
<property name="birthdate" type="date"/>
<property name="color" not-null="true"/>
<property name="sex" not-null="true"/>
<property name="weight"/>
<joined-subclass name="DomesticCat" table="DOMESTIC_CATS">
<key column="id"/>
<property name="name" type="string"/>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session session = null;
try
{
session = PersistenceSessionFactory.getCurrentSession();
Transaction transaction = session.beginTransaction();
Domestic Cat cat - new DomesticCat();
cat.setBirthdate(new Date());
cat.setColor("Black");
cat.setName("HibernateCat");
session.save(cat);
transaction.commit();
} catch (HibernateException hbx)
{
hbx.printStackTrace();
} finally
{
session.flush();
}
Problem
When I execute above, only the fields of the super class gets persisted.
The fieilds of the subclass does not gets persisted.
Any Idea?
Thanks,
Idhaya