Hello:
In the tables below I have a Many to Many relationship between Group and Role. GroupRole does the linking between these tables.
In the objects below, is it necessary to use the intermediary object to facilitate the linking?
ie: In the Group object I have a collection of
Code:
<set name="groupRoles" cascade="all-delete-orphan" lazy="true" inverse="true">
* Does this have to GroupRoles or can I have a collection Roles and if so, how would I do that?
Ultimately, I would like to expose my pojo's as web services. However, because I have Role object in Group and Group object in Role, I am creating a circular reference. How do most people avoid this?
thanks for you help.
GroupCode:
<class name="Group" table="GRP" >
<comment></comment>
<id name="grpId" type="string">
<column name="GRP_ID" length="20" />
<generator class="assigned" />
</id>
<property name="grpName" type="string">
<column name="GRP_NAME" length="40">
<comment></comment>
</column>
</property>
<property name="companyId" type="string">
<column name="COMPANY_ID" length="20">
<comment></comment>
</column>
</property>
<property name="parentGrpId" type="string">
<column name="PARENT_GRP_ID" length="20">
<comment></comment>
</column>
</property>
<property name="groupClass" type="string">
<column name="GROUP_CLASS" length="40">
<comment></comment>
</column>
<set name="groupRoles" cascade="all-delete-orphan" lazy="true" inverse="true">
<key>
<column name="GRP_ID" length="20" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="GroupRole" />
</set>
</class>
RoleCode:
<hibernate-mapping>
<class name="Role" table="ROLE" >
<comment></comment>
<id name="roleId" type="string">
<column name="ROLE_ID" length="20" />
<generator class="assigned" />
</id>
<property name="serviceId" type="string">
<column name="SERVICE_ID" length="20">
<comment></comment>
</column>
</property>
<property name="roleName" type="string">
<column name="ROLE_NAME" length="40">
<comment></comment>
</column>
</property>
<set name="grpRoles" fetch="select" cascade="all-delete-orphan">
<key>
<column name="ROLE_ID" length="20" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="GroupRole" />
</set>
</class>
</hibernate-mapping>
GroupRoleCode:
<hibernate-mapping>
<class name="GroupRole" table="GRP_ROLE" >
<comment></comment>
<id name="grpRoleId" type="string">
<column name="GRP_ROLE_ID" length="20" />
<generator class="SequenceGenerator">
<param name="table">sequence_gen</param>
<param name="column">next_id</param>
<param name="attribute">GRP_ROLE_ID</param>
</generator>
</id>
<many-to-one name="role" class="Role" fetch="select">
<column name="ROLE_ID" length="20" not-null="true">
<comment></comment>
</column>
</many-to-one>
<many-to-one name="group" class="Group" fetch="select">
<column name="GRP_ID" length="20" not-null="true">
<comment></comment>
</column>
</many-to-one>
<property name="serviceId" type="string">
<column name="SERVICE_ID" length="20" not-null="true">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>