-->
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.  [ 1 post ] 
Author Message
 Post subject: save new joined subclass object when parent already exists
PostPosted: Mon Nov 27, 2006 12:51 pm 
Newbie

Joined: Wed Nov 08, 2006 1:05 pm
Posts: 6
I have 2 classes (bpbSubmissionContainer and bpbSubmission) mapped as joined subclass (mapping below):

<class name="bo.bpbSubmissionContainer" table="bpb_baselines_t">
<id name="Id" type="Int32" column="bpb_baselines_t_id" unsaved-value="0">
<generator class="identity" />
<!--
<generator class="sequence">
<param name="sequence">bpb_projects_t_seq</param>
</generator>
-->
</id>
<property name="baselinedate" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate">
<column name="baseline_date" unique-key="baselinedateproject"></column>
</property>
<many-to-one name="project" class=".bo.bpbProject, ">
<column name="bpb_projects_t_id" unique-key="baselinedateproject"></column>
</many-to-one>
<property name="updateddt" column="updated_dt" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="createby" column="create_by" type="Nullables.NHibernate.EmptyStringType,Nullables.NHibernate" />
<property name="createdt" column="create_dt" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="updatedby" column="updated_by" type="Nullables.NHibernate.EmptyStringType,Nullables.NHibernate" />
<joined-subclass name="bo.bpbSubmission, " table="bpb_submissions_t">
<key>
<column name="bpb_submissions_t_id" unique="true"/>
</key>
<property name="collabdocid" column="collab_doc_id" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" />
<property name="submissiondate" column="submission_date" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate"
not-null="true" />
<property name="isaccurate" column="is_accurate" type="Nullables.NHibernate.NullableBooleanType, Nullables.NHibernate" />
<property name="isontime" column="is_ontime" type="Nullables.NHibernate.NullableBooleanType, Nullables.NHibernate" />
<property name="note" column="note" type="Nullables.NHibernate.EmptyStringType,Nullables.NHibernate" />
<property name="createby" column="create_by" type="Nullables.NHibernate.EmptyStringType,Nullables.NHibernate" />
<property name="createdt" column="create_dt" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="updatedby" column="updated_by" type="Nullables.NHibernate.EmptyStringType,Nullables.NHibernate" />
<property name="updateddt" column="updated_dt" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
</joined-subclass>
</class>

I have created and saved object bpbSubmissionContainer, but now I would like to save the same object as a child object: bpbSubmission.

SaveOrUpdate() give a NHibernate.StaleObjectStateException because nhibernate try to perform 2 updates (but hte 2nd update against bpbsubmission off course fails since no record exists yet)

The only things that seem to work are:
1. copying all data to B, delete A and save B. (not very useful because it creates a new id)
2. using native sql to insert id from A into B

Is there a way to do this in a "normal hibernate" style?


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

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.