Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1
Mapping documents:
<hibernate-mapping>
<class name="model.StoreDepartment"
table="store_departments">
<id name="storeDepartmentId" type="int">
<column name="store_department_id" />
<generator class="native" />
</id>
<many-to-one name="store" column="store_id" not-null="true"
cascade="save-update" lazy="false" />
...
<hibernate-mapping>
<class name="model.Store" table="stores">
<id name="storeId" type="int">
<column name="store_id" />
<generator class="native" />
</id>
<property name="storeNumber" type="string">
<column name="store_number" length="10" not-null="true" unique="true" />
</property>
..
Comments:
POJOs have the usual Store.set/getStoreDepartments(Set<StoreDepartments>), StoreDepartment.set/getStore(Store ..) methods.
I'm using the following dialect:
org.hibernate.dialect.MySQLInnoDBDialect
The tables are created with the innoDb storage engine type, but foreign key constraints aren't generated. I think this has something to do with the dialect because if I point the system at MSSQL, fk constraints are generated. Anyone have an idea what the magic for foreign keys is? <many-to-one> should be enough, I think.
Thanks,