Hello!
I'm having a small problem with a database that I'm trying to read from with Hibernate. The mapping-xml for one of the classes looks like this:
Code:
<hibernate-mapping>
<class name="UserGroupRole" table="UserGroupRole">
<composite-id name="pkObject" class="UserGroupRolePk">
<key-many-to-one name="userGroup" class="UserGroup">
<column name="userGroup"/>
<column name="applicationID"/>
</key-many-to-one>
<key-many-to-one name="userRole" class="UserRole">
<column name="userRole"/>
<column name="applicationID"/>
</key-many-to-one>
</composite-id>
</class>
</hibernate-mapping>
It's a part of a many-to-many relationship where one of the columns is used as a part of the primary key on both sides. When hibernate tries to read this it says that the class should be mapped with insert="false" update="false". That would have been possible if it wasn't for that the applicationID-field is a part of the primary key. Is there a way to work around this problem? A normal many-to-one relationship supports these attributes, but not the key-many-to-one.
I'm currently trying to run this with Hibernate 2.1 beta 2, but I get the same kind of errors with the latest stable release.
...and yes, I know this kind of db-design stinks but the actual model looks a lot worse than the simplified version I've put up here.