-->
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.  [ 2 posts ] 
Author Message
 Post subject: Closed issue: HB-1212
PostPosted: Tue Nov 22, 2005 10:44 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
I was changing my mapping files as a result of database changes and I move to use more Foreign Key references and I am now getting the folllowing when updating one of my objects:

object references an unsaved transient instance - save the transient instance before flushing: com.tascon.tim.hibernate.TimUser

I see that this is a known issue and appears to be fixed in 3.0.5, but not in any previous version [2.1.8 for example]. I was trying to avoid upgrading to 3.0.5 if at all possible.

Is there any patch available for 2.1.8?

[b]Hibernate version:2.1.8

[b]Mapping documents:

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

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.tascon.tim.hibernate.Task"
table="tasks"
>

<id
name="taskId"
type="long"
column="task_id"
>
<generator class="identity" />
</id>

<property
name="taskDueDate"
type="java.sql.Timestamp"
column="task_due_date"
length="23"
/>
<property
name="taskNotes"
type="java.lang.String"
column="task_notes"
length="1200"
/>
<property
name="taskCompleteDate"
type="java.sql.Timestamp"
column="task_complete_date"
length="23"
/>
<property
name="taskSource"
type="java.lang.String"
column="task_source"
length="10"
/>
<property
name="taskRescheduleDate"
type="java.sql.Timestamp"
column="task_reschedule_date"
length="23"
/>
<property
name="lastModifiedDate"
type="java.sql.Timestamp"
column="last_modified_date"
length="23"
/>
<property
name="lastModifiedBy"
type="java.lang.String"
column="last_modified_by"
length="20"
/>
<property
name="completeNotApplicable"
type="java.lang.Integer"
column="complete_not_applicable"
length="10"
/>

<!-- Associations -->

<!-- bi-directional many-to-one association to Contact -->
<many-to-one
name="contact"
class="com.tascon.tim.hibernate.Contact"
not-null="true"
>
<column name="contact_id" />
</many-to-one>
<!-- bi-directional many-to-one association to TimUser -->
<many-to-one
name="timUser"
class="com.tascon.tim.hibernate.TimUser"
not-null="true"
>
<column name="tim_users_id" />
</many-to-one>
<!-- bi-directional many-to-one association to LookupTaskType -->
<many-to-one
name="lookupTaskType"
class="com.tascon.tim.hibernate.LookupTaskType"
not-null="true"
>
<column name="task_type" />
</many-to-one>

</class>
</hibernate-mapping>


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

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.tascon.tim.hibernate.TimUser"
table="tim_users"
>

<id
name="id"
type="int"
column="id"
>
<generator class="identity" />
</id>

<property
name="username"
type="java.lang.String"
column="username"
not-null="true"
length="20"
/>
<property
name="passwd"
type="java.lang.String"
column="passwd"
not-null="true"
length="20"
/>
<property
name="firstname"
type="java.lang.String"
column="firstname"
length="20"
/>
<property
name="lastname"
type="java.lang.String"
column="lastname"
length="20"
/>
<property
name="isadmin"
type="java.lang.String"
column="isadmin"
length="1"
/>
<property
name="createDate"
type="java.sql.Timestamp"
column="create_date"
length="23"
/>
<property
name="isconstruction"
type="java.lang.String"
column="isconstruction"
length="1"
/>
<property
name="isSales"
type="java.lang.String"
column="is_sales"
length="1"
/>
<property
name="allReportsAccess"
type="java.lang.String"
column="all_reports_access"
length="1"
/>
<property
name="selectionUnlock"
type="java.lang.String"
column="selection_unlock"
length="1"
/>

<!-- Associations -->

<!-- bi-directional one-to-many association to SalesOpportunity -->
<set
name="salesOpportunities"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="tim_users_id" />
</key>
<one-to-many
class="com.tascon.tim.hibernate.SalesOpportunity"
/>
</set>
<!-- bi-directional one-to-many association to Task -->
<set
name="tasks"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="tim_users_id" />
</key>
<one-to-many
class="com.tascon.tim.hibernate.Task"
/>
</set>

</class>
</hibernate-mapping>


[b] Just and update of a an existing entity pulled in a different session

[b]Full stack trace of any exception that occurs:INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,250 INFO [STDOUT] Hibernate: update tasks set task_due_date=?, task_notes=?, task_complete_date=?, task_source=?, task_reschedule_date=?, last_modified_date=?, last_modified_by=?, complete_not_applicable=?, contact_id=?, tim_users_id=?, task_type=? where task_id=?
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,250 ERROR [SessionImpl] Could not synchronize database state with session
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD Type: class com.tascon.tim.util.HibernateHelper
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD Signature: catch(Exception)
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD at: HibernateHelper.java:60
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD exception: object references an unsaved transient instance - save the transient instance before flushing: com.tascon.tim.hibernate.TimUser
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD stack trace: [Ljava.lang.StackTraceElement;@fe0ce9
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] Hibernate: update tasks set task_due_date=?, task_notes=?, task_complete_date=?, task_source=?, task_reschedule_date=?, last_modified_date=?, last_modified_by=?, complete_not_applicable=?, contact_id=?, tim_users_id=?, task_type=? where task_id=?
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 ERROR [SessionImpl] Could not synchronize database state with session
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD Type: class com.tascon.tim.util.HibernateHelper
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD Signature: catch(Exception)
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD at: HibernateHelper.java:97
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD exception: object references an unsaved transient instance - save the transient instance before flushing: com.tascon.tim.hibernate.TimUser
INFO | jvm 1 | 2005/11/22 21:33:01 | 21:33:01,265 INFO [STDOUT] RRD stack trace: [Ljava.lang.StackTraceElement;@12620b5
INFO | jvm 1 | 2005/11/22 21:33:11 | 21:33:11,187 WARN [SessionImpl] afterTransactionCompletion() was never called
INFO | jvm 1 | 2005/11/22 21:33:11 | 21:33:11,187 WARN [SessionImpl] unclosed connection, forgot to call close() on your session?


[b]Name and version of the database you are using:SQL Server 2000

[b]The generated SQL (show_sql=true): See stack trace above.

[b]Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 2:48 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
I figured this out or at least an alternative solution this this problem. It now works for me.


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