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