Joined: Wed Jul 30, 2008 11:28 am Posts: 2
|
The following exception is coming, when I am trying to execute below client code.(Example).
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.sandp.care.model.AnnouncementSummaryModel
Client Code..
______________________________________________
AnnouncementModel announcementModel = new AnnouncementModel();
announcementModel.setId(1l);
IndexModel indexModel = new IndexModel();
indexModel.setId(1717l);
announcementSummaryModel.setAnnouncementModel(announcementModel);
announcementSummaryModel.setIndexModel(indexModel);
announcementSummaryModel.setEventsList(list);
announcementSummaryModel.setFlagFwdAnnct("0");
session.saveOrUpdate(announcementSummaryModel);
AnnouncementSummaryModel.hbm.xml(Parent mapping file)
________________________________________________________
<hibernate-mapping>
<class name="com.sandp.care.model.AnnouncementSummaryModel" table="CR_T_ANNOUNCEMENT_SUMMARY">
<id name="id" type="java.lang.Long">
<column name="ANNOUNCEMENT_SEQ_ID" precision="22" scale="0" />
<generator class="increment" />
</id>
<many-to-one name="announcementModel" class="com.sandp.care.model.AnnouncementModel" fetch="select" lazy="false">
<column name="ANNOUNCEMENT_ID" precision="22" scale="0" />
</many-to-one>
<many-to-one name="indexModel" class="com.sandp.care.model.IndexModel" fetch="select" lazy="false">
<column name="INDEX_ID" precision="22" scale="0" />
</many-to-one>
<bag name="eventsList" table="CR_T_EVENT_DETAILS" lazy="false" inverse="true" cascade="all">
<key column="ANNOUNCEMENT_SEQ_ID"/>
<one-to-many class="com.sandp.care.model.EventDetailsModel"/>
</bag>
</class>
</hibernate-mapping>
EventDetailsModel:(Mapping file 2):
_________________________________________________________
<hibernate-mapping>
<class name="com.sandp.care.model.EventDetailsModel" table="CR_T_EVENT_DETAILS">
<id name="id" type="java.lang.Long">
<column name="EVENT_DETAILS_ID" precision="22" scale="0" />
<generator class="increment" />
</id>
<many-to-one name="eventModel" class="com.sandp.care.model.EventModel" fetch="select" lazy="false">
<column name="EVENT_ID" precision="22" scale="0" />
</many-to-one>
<many-to-one name="announcementSummaryModel" class="com.sandp.care.model.AnnouncementSummaryModel" not-null="true">
<column name="ANNOUNCEMENT_SEQ_ID" precision="22" scale="0" />
</many-to-one>
<property name="effDate" type="java.util.Date">
<column name="EFF_DATE" length="7" />
</property>
<property name="refNo" type="java.lang.Long">
<column name="REF_NO" precision="22" scale="0" />
</property>
</class>
</hibernate-mapping>
____________________________
|
|