-->
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.  [ 4 posts ] 
Author Message
 Post subject: object references an unsaved transient instance
PostPosted: Tue Jul 27, 2004 10:36 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
Hi Guys,

I'm getting a
Code:
object references an unsaved transient instance - save the transient instance before flushing:


every time I change unsaved-value to 0 from null on my id element

Code:
<id name="id" type="int" column="link_id" unsaved-value="0">
           <generator class="identity" />
       </id>


it makes no sense to me .. do you have any clues?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 10:43 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
Code:
2004-07-27 15:40:58,585 - DEBUG (net.sf.hibernate.impl.SessionImpl:2529) - Updating entity: [com.qas.newmedia.intranet.iq.dto.schedules.ProductSchedule#426]
2004-07-27 15:40:58,585 - DEBUG (net.sf.hibernate.impl.SessionImpl:2880) - Collection found: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.updates#426], was: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.updates#426]
2004-07-27 15:40:58,585 - DEBUG (net.sf.hibernate.impl.SessionImpl:2880) - Collection found: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.links#426], was: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.links#426]
2004-07-27 15:40:58,601 - DEBUG (net.sf.hibernate.impl.SessionImpl:2776) - Processing unreferenced collections
2004-07-27 15:40:58,601 - DEBUG (net.sf.hibernate.impl.SessionImpl:2790) - Scheduling collection removes/(re)creates/updates
2004-07-27 15:40:58,601 - DEBUG (net.sf.hibernate.impl.SessionImpl:2266) - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2004-07-27 15:40:58,601 - DEBUG (net.sf.hibernate.impl.SessionImpl:2271) - Flushed: 0 (re)creations, 1 updates, 0 removals to 2 collections
2004-07-27 15:40:58,601 - DEBUG (net.sf.hibernate.impl.Printer:75) - listing entities:
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.impl.Printer:82) - com.qas.newmedia.intranet.iq.dto.schedules.ProductSchedule{associates=My Mate Marmite, created=26 June 2003 11:23:50, summary=Et quomodo invocabo deum meum, deum et dominum meum, quoniam utique inme ipsum eum invocabo, cum invocabo eum? et quis locus est in me, quoveniat in me deus meus? quo deus veniat in me, deus, qui fecit caelum et terram? itane, domine deus., qatSignoff=null, title=A test schedule by me, owner=Allistair Crossley, developmentSignoff=12 December 2004 00:00:00, launchFormat=Q4, status=Development, updates=[ScheduleUpdate#307, ScheduleUpdate#308], id=426, links=[ScheduleLink#0], developmentSignoffFormat=2004, qatSignoffFormat=Q2, lastUpdated=27 July 2004 12:15:34, launch=null}
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.impl.SessionImpl:2355) - executing flush
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.persister.EntityPersister:648) - Updating entity: [com.qas.newmedia.intranet.iq.dto.schedules.ProductSchedule#426]
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.impl.BatcherImpl:196) - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.impl.BatcherImpl:237) - update dbSchedules.dbo.tbl_Schedules set development_signoff=?, development_signoff_format=?, qat_signoff=?, qat_signoff_format=?, launch=?, launch_format=?, owner=?, associates=?, status=?, title=?, summary=?, created=?, last_updated=? where schedule_id=?
Hibernate: update dbSchedules.dbo.tbl_Schedules set development_signoff=?, development_signoff_format=?, qat_signoff=?, qat_signoff_format=?, launch=?, launch_format=?, owner=?, associates=?, status=?, title=?, summary=?, created=?, last_updated=? where schedule_id=?
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.impl.BatcherImpl:241) - preparing statement
2004-07-27 15:40:58,617 - DEBUG (net.sf.hibernate.persister.EntityPersister:388) - Dehydrating entity: [com.qas.newmedia.intranet.iq.dto.schedules.ProductSchedule#426]
2004-07-27 15:40:58,632 - DEBUG (net.sf.hibernate.impl.BatcherImpl:203) - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.impl.BatcherImpl:261) - closing statement
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.collection.AbstractCollectionPersister:553) - Deleting rows of collection: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.links#426]
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.collection.AbstractCollectionPersister:578) - no rows to delete
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.collection.AbstractCollectionPersister:710) - Updating rows of collection: com.qas.newmedia.intranet.iq.dto.schedules.Schedule.links#426
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.collection.AbstractCollectionPersister:715) - done updating rows: 0 updated
2004-07-27 15:40:58,648 - DEBUG (net.sf.hibernate.collection.AbstractCollectionPersister:592) - Inserting rows of collection: [com.qas.newmedia.intranet.iq.dto.schedules.Schedule.links#426]
2004-07-27 15:40:58,664 - DEBUG (net.sf.hibernate.impl.BatcherImpl:196) - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-07-27 15:40:58,664 - DEBUG (net.sf.hibernate.impl.BatcherImpl:237) - update dbSchedules.dbo.tbl_ScheduleLinks set schedule_id=? where link_id=?
Hibernate: update dbSchedules.dbo.tbl_ScheduleLinks set schedule_id=? where link_id=?
2004-07-27 15:40:58,664 - DEBUG (net.sf.hibernate.impl.BatcherImpl:241) - preparing statement
2004-07-27 15:40:58,664 - DEBUG (net.sf.hibernate.engine.Cascades$IdentifierValue:312) - id unsaved-value: 0
2004-07-27 15:40:58,679 - ERROR (net.sf.hibernate.impl.SessionImpl:2375) - Could not synchronize database state with session
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.qas.newmedia.intranet.iq.dto.schedules.ScheduleLink
   at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2764)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 11:13 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
Code:
       ScheduleLink scheduleLink = new ScheduleLink();       
       scheduleLink.setCreated(Calendar.getInstance());
       scheduleLink.setLabel(label);
       scheduleLink.setLink(link);
   
      try {
         Schedule schedule = scheduleLogic.load(new Integer(id));
         scheduleLink.setSchedule(schedule);
         schedule.getLinks().add(scheduleLink);
         scheduleLogic.update(schedule);
      } catch (SchedulesException sE) {
         logger.error(user.getUsername() + ": " + sE.getMessage());


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

<hibernate-mapping schema="dbSchedules.dbo">

    <class name="com.qas.newmedia.intranet.iq.dto.schedules.Schedule"
      table="tbl_Schedules">

        <id name="id" type="int" column="schedule_id" unsaved-value="0">
           <generator class="identity" />
       </id>
            
      <discriminator column="schedule_type" type="string" />
            
        <property name="owner" column="owner" not-null="false" />
      <property name="associates" column="associates" not-null="false" />
      <property name="status" column="status" not-null="false" />
      <property name="title" column="title" not-null="true" />
      <property name="summary" column="summary" not-null="false" />
      <property name="created" type="calendar" column="created" not-null="false" />
      <property name="lastUpdated" type="calendar" column="last_updated" not-null="false" />

      <set name="updates" inverse="true" order-by="created desc" lazy="true">
            <key column="schedule_id" />
            <one-to-many class="com.qas.newmedia.intranet.iq.dto.schedules.ScheduleUpdate"/>
        </set>
      
      <set name="links" inverse="true" order-by="created desc" lazy="true">
            <key column="schedule_id"/>
            <one-to-many class="com.qas.newmedia.intranet.iq.dto.schedules.ScheduleLink"/>
        </set>
      
      <!--
        - Product Schedule
        -->
      
      <subclass
         name="com.qas.newmedia.intranet.iq.dto.schedules.ProductSchedule"
         discriminator-value="Product">
         
         <property name="developmentSignoff" type="calendar" column="development_signoff" not-null="false" />
         <property name="developmentSignoffFormat" column="development_signoff_format" not-null="false" />
         <property name="qatSignoff" type="calendar" column="qat_signoff" not-null="false" />
         <property name="qatSignoffFormat" column="qat_signoff_format" not-null="false" />
         <property name="launch" type="calendar" column="launch" not-null="false" />
         <property name="launchFormat" column="launch_format" not-null="false" />
       </subclass>
      
      <!--
        - QA For Schedule
        -->      
      
      <subclass
         name="com.qas.newmedia.intranet.iq.dto.schedules.QAForSchedule"
         discriminator-value="QAFor">
         
         <property name="developmentSignoff" type="calendar" column="development_signoff" not-null="false" />
         <property name="developmentSignoffFormat" column="development_signoff_format" not-null="false" />
         <property name="qatSignoff" type="calendar" column="qat_signoff" not-null="false" />
         <property name="qatSignoffFormat" column="qat_signoff_format" not-null="false" />
         <property name="launch" type="calendar" column="launch" not-null="false" />
         <property name="launchFormat" column="launch_format" not-null="false" />
       </subclass>            

      <!--
        - Data Acquisition Schedule
        -->

      <subclass
         name="com.qas.newmedia.intranet.iq.dto.schedules.DataAcquisitionSchedule"
         discriminator-value="DataAcquisition">
                  
         <property name="productRelease" column="product_release" not-null="false" />
       </subclass>
      
      <!--
        - Project Schedule
        -->      
      
      <subclass
         name="com.qas.newmedia.intranet.iq.dto.schedules.ProjectSchedule"
         discriminator-value="Project">
                  
         <property name="approval" type="calendar" column="approval" not-null="false" />
         <property name="approvalFormat" column="approval_format" not-null="false" />
         <property name="targetCompletion" type="calendar" column="target_completion" not-null="false" />
         <property name="targetCompletionFormat" column="target_completion_format" not-null="false" />
       </subclass>             

    </class>
   
   <class name="com.qas.newmedia.intranet.iq.dto.schedules.ScheduleUpdate"
      table="tbl_ScheduleUpdates">

        <id name="id" type="int" column="update_id" unsaved-value="0">
           <generator class="identity" />
       </id>

      <property name="created" type="calendar" not-null="true" />
      <property name="author" column="author" not-null="true" />
      <property name="comment" column="comment" type="text" length="4096" not-null="true" />
      <property name="internal" column="internal" type="boolean" />
      
      <many-to-one
            name="schedule"
            column="schedule_id"
            not-null="true" />         
   </class>
   
   <class name="com.qas.newmedia.intranet.iq.dto.schedules.ScheduleLink"
      table="tbl_ScheduleLinks">

        <id name="id" type="int" column="link_id" unsaved-value="0">
           <generator class="identity" />
       </id>

      <property name="created" type="calendar" not-null="true" />
      <property name="label" column="label" not-null="true" />
      <property name="link" column="link" not-null="true" />
      
      <many-to-one
            name="schedule"
            column="schedule_id"
            not-null="true" />
         
   </class>   

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 11:52 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
i needed a bi-directional coupling as demonstrated by the parent-child example.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.