-->
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: Save Error: Identifier of an instance altered
PostPosted: Fri Oct 10, 2003 4:51 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
I have a pretty straight forward one-to-many relationship modeled, and I keep receiving the following error:

CMSProcessor::processAddition--Update Failed net.sf.hibernate.HibernateException: identifier of an instance of forecastingModel.Tunnel altered from 21 to 21

(where 21 is the generated sequence number).


In this scenario, I'm simply creating one new parent and one new child object, adding the child to the parents collection, and then calling session.save(parent). The debug log didn't seem to add much detail.


Here's the segment from my log file, and the mappings for parent and child are below that.

Thanks for any help,
Brandon


16:33:21,304 DEBUG BatcherImpl:166 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:33:21,304 DEBUG SessionFactoryImpl:526 - prepared statement get: select hibernate_sequence.nextval from dual
16:33:21,366 DEBUG SequenceGenerator:70 - Sequence identifier generated: 21
16:33:21,366 DEBUG BatcherImpl:173 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:33:21,382 DEBUG SessionImpl:656 - saving [forecastingModel.Tunnel#21]
16:33:21,398 DEBUG SessionImpl:2520 - Wrapped collection in role: forecastingModel.Tunnel.genericUsages
CMSProcessor::processAddition--save usage
[10/10/03 16:33:21:413 EDT] 4c98f36c SystemOut O CMSProcessor::processAddition--save tunnel 21
[10/10/03 16:33:21:413 EDT] 4c98f36c SystemOut O 16:33:21,413 DEBUG JDBCTransaction:54 - commit
16:33:21,413 DEBUG SessionImpl:2011 - flushing session
16:33:21,429 DEBUG SessionImpl:2113 - Flushing entities and processing referenced collections
16:33:21,429 DEBUG SessionImpl:447 - transaction completion
CMSProcessor::processAddition--Update Failed net.sf.hibernate.HibernateException: identifier of an instance of forecastingModel.Tunnel altered from 21 to 21
[10/10/03 16:33:21:429 EDT] 4c98f36c SystemOut O 16:33:21,429 DEBUG JDBCTransaction:77 - rollback
16:33:21,444 DEBUG SessionImpl:447 - transaction completion
16:33:21,444 DEBUG SessionImpl:435 - closing session
16:33:21,444 DEBUG SessionImpl:2930 - disconnecting session
16:33:21,444 DEBUG DriverManagerConnectionProvider:117 - returning connection to pool, pool size: 1
16:33:21,444 DEBUG SessionImpl:447 - transaction completion



<hibernate-mapping>
<class name="forecastingModel.Tunnel" table="tunnel">
<id
name="tunnelID"
column="tunnel_ID" type="integer">
<generator class="native"/>
</id>


<property name="materialNumber" column="material_number" type="string" length="25"/>
<property name="forecastKey" column="forecast_key" type="string" length="50"/>
<property name="marketType" column="market_type" type="string" length="10"/>
<property name="distributionChannel" column="distribution_channel" type="string" length="10"/>
<property name="clubCode" column="club_code" type="string" length="4"/>
<property name="componentType" column="component_type" type="string" length="10"/>
<property name="usageType" column="usage_type" type="string" length="10"/>
<property name="contentCode" column="content_code" type="string" length="10"/>
<property name="lastMailDate" column="last_mail_date" type="date"/>
<many-to-one name="theAttritionCurve"/>
<many-to-one name="theAutoshipmentCurve"/>
<many-to-one name="theAutoshipmentReturnCurve"/>
<many-to-one name="theAutoReturnInfo"/>
<many-to-one name="theCutoverIndicator"/>
<many-to-one name="thePriceChangeFactor"/>
<many-to-one name="theResponseCurve"/>
<many-to-one name="theSizeChangeFactor"/>
<many-to-one name="theNewMemberGroupingGrid"/>


<list
name="genericUsages"
lazy="true"
inverse="true">
<key column="theTunnel"/>
<index column="sequence_number"/>
<one-to-many class="forecastingModel.GenericUsage"/>
</list>


</class>

</hibernate-mapping>


/*child mapping*/
<hibernate-mapping>
<class name="forecastingModel.GenericUsage" table="generic_usage" discriminator-value="G">

<id name="usageId" column="usage_ID" length="10" type="string">
<generator class="assigned"/>
</id>
<discriminator column="usagetype" type="character"/>
<property name="actualPullRate" column="actual_pull_rate" type="long"/>
<property name="attritionRate" column="attrition_rate" type="long"/>
<property name="cmsPullRate" column="cms_pull_rate" type="long"/>
<property name="componentProductId" column="component_prod_id" type="string" length="10"/>
<property name="cutoverDate" column="cutover_date" type="date"/>
<property name="forecastedDemand" column="forecasted_demand" type="integer"/>
<property name="forecastingPullRate" column="forecasting_pull_rate" type="long"/>
<property name="labelRunDate" column="label_run_date" type="date"/>
<property name="mailDate" column="mail_date" type="date"/>
<property name="materialNumber" column="material_number" type="string" length="10"/>
<property name="membersAddressed" column="members_addressed" type="integer" length="10"/>
<property name="overridePullRate" column="override_pull_rate" type="long"/>
<property name="pageSize" column="page_size" type="long"/>
<property name="pageSizeChangeFactor" column="pagesize_change_factor" type="long"/>
<property name="partialMatchSourceID" column="partial_match_source_id" type="string" length="10"/>
<property name="price" type="long"/>
<property name="priceChangeFactor" column="price_change_factor" type="long"/>

<property name="salesToDate" column="sales_to_date" type="integer"/>
<property name="sequenceNumber" column="sequence_number" type="integer"/>
<property name="channel" type="string" length="10"/>
<property name="clubPrice" column="club_price" type="long"/>
<property name="componentId" column="component_id" type="string" length="10"/>
<property name="componentType" column="component_type" type="string" length="10"/>
<property name="contentCode" column="content_code" type="string" length="10"/>
<property name="countAs" column="count_as" type="integer"/>
<property name="marketType" column="market_type" type="string" length="10"/>
<property name="negativePullRate" column="negative_pull_rate" type="long"/>
<property name="packageId" column="package_id" type="string" length="10"/>
<property name="percentOfPage" column="percent_of_page" type="long"/>
<property name="promoPeriodId" column="promo_period_id" type="string" length="4"/>
<property name="promoScheduleId" column="promo_schedule_id" type="string" length="4"/>
<property name="pullRate" column="pull_rate" type="long"/>
<property name="usageType" column="usage_type" type="string" length="10"/>
<property name="clubCode" column="club_code" type="string" length="4"/>





<subclass name="forecastingModel.CurrentMemberUsage" discriminator-value="C">
<property name="refusalToDate" column="refusal_to_date" type="integer"/>
<many-to-one name="theAutoshipment" class="forecastingModel.Autoshipment"/>
</subclass>

<subclass name="forecastingModel.NewMemberUsage" discriminator-value="N">
<property name="enrollToDate" column="enroll_to_date" type="integer"/>
</subclass>
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2003 10:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You usually get this if Hibernate generates a Long, and you keep it as an Integer, or something of that sort.

new Integer(21).equals( new Long(21) )

evaluates to false.


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.