hello every one,
I have read the the docs and searched in the forum but since I am new to hibernate, i had some difficulty in udnerstanding the concept.
Database tables : groups (groupId), users (userId) and groups_users (groupId, userId).
I have two hbm files and 2 POJOs each corresponding to groups.
Do i need to have a POJO and a hbm.xml file for the link table whcih is group_user?
How do I write a query to obtain all the users that belong to a group.
Following are the hbm.xml files. Thanks a ton for your time!
Code:
<class name="pojo.Groups" table="GROUPS">
<id name="groupId" column="groupId">
<generator class="increment"/>
</id>
<property name="groupName"/>
<set name="users" table="GROUP_USER"
inverse="true"
cascade="save-update"
lazy="true"
>
<key column="groupId"/>
<many-to-many column="userId" class="pojo.Users"/>
</set>
</class>
----------------------------------------------------------
<class name="pojo.Users" table="USERS">
<id name="userId" column="id">
<generator class="increment"/>
</id>
<property name="login"/>
<property name="firstName"/>
<property name="lastName"/>
<property name="phone"/>
<property name="email"/>
<property name="password"/>
<set name="groups" table="GROUP_USER"
inverse="true"
cascade="save-update"
lazy="true">
<key column="userId"/>
<many-to-many column="groupId" class="pojo.Groups"/>
</set>
</class>
[/list]