I'm having some difficulties with the DDL generated by the SchemaExport tool. Using Hibernate 2.1.1, MySQL dialect.
Here's the setup. I have 3 mapping files(Item, GroupItemAttachment, GroupItemInclude ). Item is a class heirarchy which includes GroupItem as a joined-subclass. GroupItemAttachment and GroupItemInclude both map a many-to-one relationship to a GroupItem :
Code:
...
<many-to-one name="groupItem" column="IC_GROUP_ITEM_UID" class="GroupItem" not-null="true"/>
...
Item mapping snippets:
Code:
<hibernate-mapping package="com.tirzmax.data.inventory">
<class name="Item" table="IC_ITEM" lazy="true">
<id name="uid" column="IC_ITEM_UID" type="string" length="32">
<generator class="uuid.hex"/>
</id>
...
<!-- GROUPITEM SUBCLASS -->
<joined-subclass name="GroupItem" table="IC_GROUP_ITEM" lazy="true">
<key column="IC_ITEM_UID"/>
<property name="collapsed" column="COLLAPSED" type="boolean" not-null="true"/>
<set name="includes" lazy="true" inverse="true">
<key column="IC_ITEM_UID"/>
<one-to-many class="GroupItemInclude"/>
</set>
<set name="attachments" lazy="true" inverse="true">
<key column="IC_ITEM_UID"/>
<one-to-many class="GroupItemAttachment"/>
</set>
</joined-subclass>
</class>
</hibernate-mapping>
Notice the key length of 32 for the Item class heirarchy. The DDL generated for the GroupItemInclude class is fine. By fine I mean the IC_GROUP_ITEM_UID column has the appropriate length of 32. However, the DDL for the GroupItemAttachment class has a length of 255 for the IC_GROUP_ITEM_UID column. The order that the tables are output is GroupItemAttachment, GroupItem, GroupItemInclude.
For some reason SchemaExport is not recognizing the size restriction on that column in this instance. I have other classes mapped, but their FKs all come out just fine. For examples, there is a Company class with the same length restriction on the PK that just about every class references and they all have a length of 32. The Company DDL is way down in the output order( well past FKs that are pointing to it ).
Any suggestions??