Hello All,
I have something of an odd setup that I cannot seem to get to work properly. I have roles and functions... while roles are stored on the database it makes sense to store the functions on the jre. When I try to update a role it acts as if there can only be one of each function... IE if I try to update role 1 with function a and b then it works... but if I then try to update role 2 with just function a then role 1 will have function b and role 2 will have function a... let me show you my setup.
Role.hbm.xml
Code:
<hibernate-mapping package="nhweb.obj">
<class name="Role" table="role">
<id name="id" type="int" column="role_id">
<generator class="increment"/>
</id>
<set name="permissions" cascade="all" lazy="false" fetch="join">
<key column="role_id" not-null="true" />
<one-to-many class="Function" />
</set>
<property name="name" type="string" column="name" />
</class>
</hibernate-mapping>
Function.hbm.xml
Code:
<hibernate-mapping package="nhweb.obj">
<class name="Function" table="permissions">
<id name="id" type="int" column="function_id" />
</class>
</hibernate-mapping>
Basically the permissions table keeps track of all the function_ids that have been assigned to a role. It is probably very obvious what my mistake is but I have been messing with this for some time now so please help... I am guessing it has something to do with Function.hbm.xml having function_id as a primary key but it isnt...