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.  [ 3 posts ] 
Author Message
 Post subject: Transient Exception
PostPosted: Wed Mar 22, 2006 11:59 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
Hi,
I get this exception when I try to save an object (Template) to the DB.
I'm really stuck up with this error and any help would be deeply appreciated.

com.ge.healthcare.gehcit.ehrae.flowsheet.dto.TemplateGroup; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ge.healthcare.gehcit.ehrae.flowsheet.dto.TemplateGroup

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ge.healthcare.gehcit.ehrae.flowsheet.dto.PatientFlowsheetElement

at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)



My HBM files.

/*********Template***********************/
Code:
    <class name="Template" table="TEMPLATE">

        <id name="templateId" column="TEMPLATE_ID" type="java.lang.Integer" >
            <generator class="native"/>
        </id>
        <timestamp name="updateOn" column="update_on"/>
        <property name="templateName" column="TEMPLATE_NAME" type="java.lang.String"  not-null="true" />
       
        <property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String"  not-null="true" />

        <many-to-one name="groupId" column="GROUP_ID" class="TemplateGroup"/>

        <bag name="templateElements" table="template_element" cascade="save-update,delete" inverse="true" lazy="false">
            <key not-null="true" column="TEMPLATE_ID" />
            <one-to-many class="TemplateElement"/>
        </bag>       

    </class>


/*********Template Group***********************/

Code:
    <class name="TemplateGroup" table="template_group">

        <id name="groupId" column="GROUP_ID" type="java.lang.Integer">
            <generator class="native"/>
        </id>
  <timestamp name="updateOn" column="update_on"/>

        <property name="groupName" column="GROUP_NAME" type="java.lang.String"  not-null="true" />


        <property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String"  not-null="true" />
     
       <many-to-one name="property" column="PROPERTY_ID" class="Property"/>

<set name="childTemplates" table="template" cascade="save-update,persist,merge" lazy="false">
      <key column="GROUP_ID" />
      <one-to-many class="Template" />
</set>
    </class>


I think this is related to the many-to-one mapping. I'm not quite sure why I'm getting this exception.
Any help would be deeply appreciated.

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 2:46 pm 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
You don't tell when the exception occurs so I'm guessing it is when you want to save a Template object. Try to add cascade="save-update" to the many-to-one element in Template hbm file


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 3:07 pm 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
I had solved that issue,
but have come up with the same Exception in another place.

Every time I try to save a new PatientFlowsheetElement Object, It throws the same exception.

Hibernate has an update="false" in <many-to-one> tag, but
How do I give an update="false" on <key-many-to-one> tag.

How do I tell Hibernate that when you are trying to insert the parent object, don't try to insert the object which is supplied for insertion of key value in the parent Object.

/********************PatientFlowsheetElementParam**************/
Code:
    <class name="PatientFlowsheetElementParam" table="patient_flowsheet_element_param">

        <composite-id name="id">
            <key-many-to-one name="patientFlowsheetElementId" column="PATIENT_FLOWSHEET_ELEMENT_ID" class="PatientFlowsheetElement"/>

            <key-many-to-one name="parameterId" column="PARAMETER_ID" class="com.ge.healthcare.gehcit.ehrae.variable.dto.Variable" />
        </composite-id>

<timestamp name="lastUpdateTime" column="LAST_UPDATE_TIME"/>

      <property name="sequence" column="SEQUENCE" type="java.lang.Integer"  not-null="true" />

        <property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String"  not-null="true" />

   </class>


/********************PatientFlowsheetElement**************/

Code:
    <class name="PatientFlowsheetElement" table="patient_flowsheet_element" dynamic-update="false">

        <id name="patientFlowsheetElementId" column="PATIENT_FLOWSHEET_ELEMENT_ID" type="java.lang.Integer">
            <generator class="native"/>
        </id>

   <timestamp name="lastUpdateTime" column="LAST_UPDATE_TIME"/>

        <property name="elementType" column="ELEMENT_TYPE" type="java.lang.String"  />

        <property name="elementName" column="ELEMENT_NAME" type="java.lang.String"  />

        <property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" />

        <property name="sequence" column="SEQUENCE" type="java.lang.Integer" />

    <many-to-one name="patientFlowsheet" column="PATIENT_FLOWSHEET_ID" class="PatientFlowsheet"/>

        <many-to-one name="patientFlowsheetElement" column="PATIENT_FLOWSHEET_PARENT_ID" class="PatientFlowsheetElement" />

        <bag name="childPatientFlowsheetElements" table="patient_flowsheet_element" cascade ="save-update,delete" inverse="true" lazy="false">
            <key column="PATIENT_FLOWSHEET_PARENT_ID" />
            <one-to-many class="PatientFlowsheetElement"/>
        </bag>

        <set name="patientFlowsheetElementParams" table="patient_flowsheet_element_param" cascade="save-update,delete" inverse="true" lazy="false">
            <key column="PATIENT_FLOWSHEET_ELEMENT_ID" />
            <one-to-many class="PatientFlowsheetElementParam" />
        </set>

    </class>



Any help would be deeply appreciated. Please tell me if you are not able to understand. I'll try rephrasing my question.

_________________
Please vote if my Postings helps. :-)


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

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.