These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Subclass and One-to-One relationship
PostPosted: Wed Jun 22, 2005 4:22 pm 
Newbie

Joined: Thu May 05, 2005 2:34 pm
Posts: 4
Location: Charlotte,NC
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.