[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4915) <list-index> base attribute ignored on insert for a bidirectional association (one-to-many)

Olivier Lafontaine (JIRA) noreply at atlassian.com
Fri Feb 12 23:52:29 EST 2010


<list-index> base attribute ignored on insert for a bidirectional association (one-to-many)
-------------------------------------------------------------------------------------------

                 Key: HHH-4915
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4915
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.5.0-CR-1, 3.3.2
         Environment: Hibernate 3.3.2GA and 3.5.0-CR-1
Oracle Database
            Reporter: Olivier Lafontaine
         Attachments: hibernate-poc-jira.zip

My mapping looks like the following:
{code:xml}
<hibernate-mapping>

    <class name="Parent">
        
        <!-- SNIP -->
        
	<list name="children" table="CHILD" cascade="all-delete-orphan">
		<key column="ID_PARENT" not-null="true" />
		<list-index base="1">
		    <column name="IDX" check="IDX > 0" />
		</list-index>
		<one-to-many class="Child" />
	</list>

    </class>
    
    <class name="Child">

        <!-- SNIP -->
        
	<many-to-one name="parent" class="Parent" column="ID_PARENT"
		not-null="true" insert="false" update="false" />
    </class>
    
</hibernate-mapping>
{code}

As you can see from the mapping, we have a parent entity ({{Parent}}) referring child entities ({{Child}} using the {{children}} accessor). The index column ({{ORDER}}) is not an attribute in the child entity, so I referred to the second use case in section _6.3.3. Bidirectional associations with indexed collections_ of the reference guide to do my mapping. 

Everything works except for the index base, it is always 0 based on insert. I've tried both Hibernate 3.3.2GA and the latest development version (3.5.0-CR-1), the issue can be reproduced in both.

I've joined a test case to reproduce the problem. While working on it, I realized there are updates after the inserts setting the correct index. However, we cannot change the database schema and there's a constraint on the index column enforcing a value > 0. So this issue is really important for us. I could manually handle the index values, but it would be so much easier to let Hibernate do it.

I've traced the problem and it seems that {{StatefulPersistenceContext#getIndexInParent(..)}} does not considers the index base. Why are updates necessary after the inserts? It looks to me like Hibernate could correctly set the index parameter on the insert statements.


-- 
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