I have two classes Application and BusinessUnit that are related via a many-to-many bi-directional relationship:
In application.hbm.xml:
Code:
<set name="businessUnits" inverse="true" table="ApplicationBusinessUnit">
<key>
<column name="applicationId" not-null="true" />
</key>
<many-to-many entity-name="com.abnamro.appinv.model.BusinessUnit">
<column name="businessUnitId" not-null="true" />
</many-to-many>
</set>
In businessunit.hbm.xml:
Code:
<set name="applications" inverse="true" table="ApplicationBusinessUnit">
<key>
<column name="businessUnitId" not-null="true" />
</key>
<many-to-many entity-name="com.abnamro.appinv.model.Application">
<column name="applicationId" not-null="true" />
</many-to-many>
</set>
The relationship loads correctly from the database, but any attempt to change the relationship does not persist to the database. As an example, creating a new relationship between an existing Application and an existing BusinessUnit does not get persisted even if I add the BusinessUnit to the collection on the Application and add the Application to the collection on the BusinessUnit and explicitly update both the Application and the BusinessUnit within the same session and transaction.
No exceptions are thrown, the update just never seems to happen. I have not included an cascade-on-update to either entity as I only want to change the association, not the objects themselves. Anyone else notice similar behaviour?
Any help would be much appreciated.
Thanks
Mike Horwitz
Hibernate version:
3.2.0
Name and version of the database you are using:
MS SQL Server 8