-->
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: Inheritance issue
PostPosted: Fri Dec 02, 2005 10:23 am 
Newbie

Joined: Tue Sep 27, 2005 10:12 am
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.05

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class entity-name="Event" polymorphism="implicit">
<id name="event_id" type="long" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="Name" type="string" column="Event_Name"/>
<property name="StartDate" type="date" column="Start_Date"/>
<property name="Duration" type="int" column="Event_Duration"/>
<joined-subclass entity-name="Conference_Event">
<key column="event_id"/>
<property name="FoodProvided" type="string" column="Food_Provided"/>

</joined-subclass>
<joined-subclass entity-name="Networking_Event">
<key column="event_id"/>
<property name="NumberOfSeats" type="int" column="Num_Seats"/>

<joined-subclass entity-name="Enterprise_Event">
<key column="event_id"/>
<property name="ParticipantName" type="string" column="Participant_Name"/>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>

I am facing the following issues:
1) I am not allowed to insert records into database at a level higher than leaf node ie. if I try to insert a record only upto "Networking_Event" , I get the following error:

Exception in thread "main" org.hibernate.HibernateException: instance not of expected entity type: Networking_Event
at org.hibernate.persister.entity.BasicEntityPersister.getSubclassEntityPersister(BasicEntityPersister.java:2995)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1094)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:409)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:82)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at EventManager.save(EventManager.java:61)
at EventManager.main(EventManager.java:49)

Thus I am forced to to insert record upto leaf node ie."Enterprise_Event" to comeplete the DB transaction successfully.

2) I am not able to get the records from table "Event" only.I get all the records stored in the entire hierarchy.

Can some one help me how to fix this issue.

Thanks in Advance
vasu


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.