• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Many to ManyMapping  RSS feed

meghna kapoor
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am developing an application in Spring and has integrated it with Hibernate.
I have a User table, UserGroup table with following schema
User has employeeId as primary key and also has a set like this
<set name="usergrp" table="user_group" cascade="all">
<key column="employeeId" />
<many-to-many column="id" class="in.netambit.domain.UserGroup" />
And have UserGroup table with grpId and grpName
I have achieved the many to many mapping that a user can have mutiple usergroups and multiple user can have same group.

Here are the tables
employeeId employeeName
admin Meghna
kuldeep kuldeep
richa Richa

UserGroup table
userId userGrpName
1 'Admin'
2 'Supervisor'
3 'General'

And due to this mapping i got a user_group table in database which contains the relationship between the two onjects


employeeId id
admin 1
richa 3
kuldeep 2

Now this user_group has all the entries of user who are supervisors

Now i want to achieve many to many relationship between user and supervisor
i know this can be achieved if i have the supervisor table but i dont have this. All the user who are supervisors are mapped in user_group table. Which is not an object in Hibernate .
i want to have a single table assigned_supervisor with user and supervisor relationship

like this
employeeId supId
richa kuldeep

here richa is the employee id of a general user and he is assigned a supervisor with employee id kuldeep

How to achieve this?

this is very urgent

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!