I have a many to many indexed relation described by the mapping below. The SchemaExport is assuming that the primary key for the link table is one of the primary key plus the position field. I see how that works for a one-to-many relationship but is not good for a many-to-many.
Has anyone encountered this problem? Is there a work around?
Hibernate version:
3.1.3
Mapping documents:
<hibernate-mapping>
<class name="cma.model.Content" table="cma_content">
<id name="contentPk" column="content_pk" unsaved-value="null">
<!-- The generator-class attribute of @hibernate.id is deprecated, use the @hibernate.generator tag instead -->
<generator class="increment"></generator>
</id>
<array name="children" table="cma_parent2children">
<key column="children_pk"></key>
<list-index column="position"></list-index>
<many-to-many class="cma.model.Content" column="parent_pk"></many-to-many>
</array>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using:
MySql 4.1
The generated SQL (show_sql=true):
create table cma_parent2children (children_pk bigint not null, parent_pk bigint not null, position integer not null, primary key (children_pk, position)) type=InnoDB;
|