Skip to:
I used the following hbm's:
------------Parent-------------------- <hibernate-mapping> <class name="test.hibernate.Parent" table="Parent"> <id name="id" type="Int64" unsaved-value="null" > <column name="id"/> <generator class="native"/> </id> <set name="children" table="Parent_Child"> <key column="parent_id"/> <many-to-many class="test.hibernate.Child" column="child_id" /> </set> </class> </hibernate-mapping>
----------------Child------------------- <hibernate-mapping> <class name="test.hibernate.Child" table="Child"> <id name="id" type="Int64" unsaved-value="null" > <column name="id"/> <generator class="native"/> </id> </class> </hibernate-mapping>
When I call Cfg.GenerateSchemaCreationScript() it returns the following schema script:
create table Parent_Child (parent_id BIGINT not null, child_id BIGINT null)
create table Parent (id BIGINT IDENTITY NOT NULL, primary key (id))
create table Child (id BIGINT IDENTITY NOT NULL, primary key (id))
alter table Parent_Child add constraint FK5AF11D477B66B0D0 foreign key (parent_id) references Parent
alter table Parent_Child add constraint FK5AF11D4762EA171E foreign key (child_id) references Child
Notice that on the Parent_Child table there is no PK and the child_id is NULL when it sould be NOT NULL.
NOTE: I ran the exact same hbm's using java Hibernate and the generated schema includes all the missing attributes.
Fixed in CVS
I used the following hbm's:
------------Parent--------------------
<hibernate-mapping>
<class name="test.hibernate.Parent" table="Parent">
<id name="id" type="Int64" unsaved-value="null" >
<column name="id"/>
<generator class="native"/>
</id>
<set name="children" table="Parent_Child">
<key column="parent_id"/>
<many-to-many class="test.hibernate.Child" column="child_id" />
</set>
</class>
</hibernate-mapping>
----------------Child-------------------
<hibernate-mapping>
<class name="test.hibernate.Child" table="Child">
<id name="id" type="Int64" unsaved-value="null" >
<column name="id"/>
<generator class="native"/>
</id>
</class>
</hibernate-mapping>
When I call Cfg.GenerateSchemaCreationScript() it returns the following schema script:
create table Parent_Child (parent_id BIGINT not null, child_id BIGINT null)
create table Parent (id BIGINT IDENTITY NOT NULL, primary key (id))
create table Child (id BIGINT IDENTITY NOT NULL, primary key (id))
alter table Parent_Child add constraint FK5AF11D477B66B0D0 foreign key (parent_id) references Parent
alter table Parent_Child add constraint FK5AF11D4762EA171E foreign key (child_id) references Child
Notice that on the Parent_Child table there is no PK and the child_id is NULL when it sould be NOT NULL.
NOTE: I ran the exact same hbm's using java Hibernate and the generated schema includes all the missing attributes.