-->
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.  [ 5 posts ] 
Author Message
 Post subject: List index values being set to all zeros
PostPosted: Fri Feb 13, 2004 6:35 pm 
Regular
Regular

Joined: Wed Sep 03, 2003 9:56 pm
Posts: 58
I have an indexed one-to-many mapping. I add four children and save(), and the indices are 0..3 in the database. When the next child is added, for some reason the first four indices get set to zero, and the last one set to 4 (so now I have 0, 0, 0, 0, 4 in the database). Obviously a problem.

My (simplified) mappings are as follows:
Code:
<hibernate-mapping>
    <class name="Envelope" table="ENVELOPE">
        <id.../>
        <one-to-one name="remittanceData" property-ref="envelope" class="RemittanceData"/>
        <list name="stateHistory" table="ENV_STATE_HIST" cascade="all-delete-orphan" inverse="true">
            <key column="ENVELOPE_ID"/>
            <index column="SEQ"/>
            <one-to-many class="StateHistory"/>
        </list>
    </class>

    <class name="StateHistory" table="ENV_STATE_HIST">
        <id .../>
        <property column="SEQ" name="sequence"/>
        <many-to-one column="ENVELOPE_ID" name="envelope"/>
        <many-to-one column="STATE_ID" name="state" class="StateBase"/>
    </class>
</hibernate-mapping>

and here is the offending SQL statement (from the log):
Code:
14:12:11,812 DEBUG SQL:223 - update ENV_STATE_HIST set SEQ=?, ENVELOPE_ID=?, STATE_ID=?, CREATED=?, CREATED_BY=? where ID=?
Hibernate: update ENV_STATE_HIST set SEQ=?, ENVELOPE_ID=?, STATE_ID=?, CREATED=?, CREATED_BY=? where ID=?
14:12:11,812 DEBUG BatcherImpl:227 - preparing statement
14:12:11,843 DEBUG EntityPersister:389 - Dehydrating entity: [StateHistory#2745]
14:12:11,843 DEBUG IntegerType:46 - binding '0' to parameter: 1
14:12:11,859 DEBUG LongType:46 - binding '687' to parameter: 2
14:12:11,859 DEBUG Cascades:341 - id unsaved-value strategy NULL
14:12:11,875 DEBUG LongType:46 - binding '0' to parameter: 3
14:12:11,875 DEBUG TimestampType:46 - binding '13 February 2004 14:06:41' to parameter: 4
14:12:11,906 DEBUG StringType:46 - binding 'test user' to parameter: 5
14:12:11,906 DEBUG LongType:46 - binding '2745' to parameter: 6
...(three more that also bind 0 to parameter: 1)...


I just can't for the life of me figure out why these updates are happenning.

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 6:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Lists are not officially supported for parent-child many-to-one mappings. There are workaround using an explicitly mapped index property in the child. Search the forum.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 6:42 pm 
Regular
Regular

Joined: Wed Sep 03, 2003 9:56 pm
Posts: 58
I apologize if I'm missing something obvious. I thought that I was using an explicitly mapped index property in the child (which I got by searching the forum ;) ).

Am I misunderstanding your statement?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 6:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes you are. But you are most likely not managing the index property correctly in the child. Look at http://forum.hibernate.org/viewtopic.php?t=926946&highlight=mapped+index+list+child


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 7:07 pm 
Regular
Regular

Joined: Wed Sep 03, 2003 9:56 pm
Posts: 58
(updated wrong subject. Sorry)

Works perfectly.

Thanks so much.
-Mitch


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