views:

44

answers:

1

Using hibernate and Hsqldb - a list of objects are session.merged through a transaction. When session.flush() is called I get a "duplicate column name in column list: x" where x is the first column.

The database table has no duplicate columns and I am able to read the data allright. The table does contain a composite primary key which I am handling in the mapping file as:

    <composite-id>
        <key-property name="x"></key-property>
        <key-property name="y"></key-property>
    </composite-id>
    <property name="x" type="string" unique="false"
        optimistic-lock="true" lazy="false" generated="never">
        <column name="X" length="10" not-null="true" unique="false" />
    </property>
    <property name="y" type="string" unique="false"
        optimistic-lock="true" lazy="false" generated="never">
        <column name="Y" length="18" not-null="true"
            unique="false" />
    </property>

Thanks

A: 

You are mapping the X & Y twice. If you say it is a composite ID there is no need to re-map it as a property.

<composite-id>
    <key-property name="x"></key-property>
    <key-property name="y"></key-property>
</composite-id>
Pedro
I thought that, but when I entered the other information in the property mapping into the property-key mapping I got all sorts of undefined errors. I've inherited this mapping file from the application.
Trevor
I tried the suggestion removing the other attributes from the property declaration. Now I get a merge error (before I get to flush) which may be associated with using underscore. The property and column name are both x_x, but when the second object is merged it shows that "xx" is allready merged to "null." I would have expected to see x_x on the error message.
Trevor
Could you post both mapping and table schema? Thank you.
Pedro
Removed the additional mapping - then to make it work added following to composite-id: <composite-id class="classname" mapped="true"> <key-property name="x" column="X" type="string"></key-property> <key-property name="y" column="Y" type="string"></key-property> </composite-id>
Trevor