tags:

views:

58

answers:

1

Hi i an using Hibernate tool with eclipse ganymede 3.4.1 . Now when i create the .hbm.xml file using the code generation of Hibernate tool,it is automatically creating a composite key. I am adding the code over here :

but i need a mapping something like

        <id name="id" type="java.lang.Integer">
            <column name="id" />
        </id>
        <key-property name="name" type="string">
            <column name="name" length="30" />
        </key-property>
        </class>

. can someone tell me how to do it.

Thanks in advance, Rima

+1  A: 

The tool somehow got that your table structure has a composite primary key (id, name). If this is the table structure than the tool didn't got it wrong. Or maybe it just has a bug.

Anyway if you to have a unique index on the "name" field you should map it like:

<property name="name" type="string" unique="true">
    <column name="name" length="30"/>
</property>

<key-property> tag is used in <composite-id> tag to define multiple properties as identifier properties.

Bojan Milenkoski