[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3645) Bug with list when rearranging - treat it as urgent

leela (JIRA) noreply at atlassian.com
Thu Dec 11 15:43:38 EST 2008


Bug with list when rearranging - treat it as urgent
---------------------------------------------------

                 Key: HHH-3645
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3645
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.3.1
            Reporter: leela


Class A has a child list specifying an association to another class B. 

Table A  
AId 	 

Table B 
BId

Table C(Association Table with 3 columns) 
AId(Id of Table A) 
BId(Id of Table B) 
SeqNo 
OtherColumn1
OtherColumn2

When I rearrange the child list, obviously the index will be changing. 

Initially the table C was mapped like this before rearranging.
A1 B1 0 XX YY
A1 B2 1 YY ZZ
A1 B3 2 ZZ XX

After rearranging the java list contains : 
A1 B2 0 XX YY
A1 B1 1 XX YY
A2 B3 2 ZZ XX

But when this list is getting persisted, hibernate is trying to do an update by seq no 

update tablec set table Bid = B2 where Aid = A1 and SeqNo = 0 

It fails to persit because since we had set a unique composite index on AId and BId.

That means hibernate was trying to persist like this, that caused the failures. 
A1 B2 0 
A1 B2 1 
A1 B3 2 

Here is my hibernate mapping in classA mapping file. 
<list name="assocList" 
lazy="true" 
access="field" 
cascade="save-update" 
outer-join="false" 
table="tablec"> 
	<key column="aid" not-null="true" unique="false"/> 
	<list-index column="seqno"/> 
	<composite-element class="ClassC"> 
		<many-to-one name="ClassB" column="bid" lazy="proxy"/> 
		<property ..../>
		<property ..../>
	</composite-element> 
</list> 

Should not hibernate supposed to delete and reinsert the child elements? Then what is the solution for this? Is not this a bug?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list