• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate inheritance and relation

 
mark smith
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i'm a newbie with hibernate, i have 2 tables in a mysql database, i have some java class and i need to mapp them to the database

i have 2 class who extend of my main class

class

abstract Role
List<Transiger> mTransiger;


User extends role
login
password
List<Id> mGroupId


Group extends role
List<Id> mUserIds


Id
lgVal
strVal

it' lgVal who will be generated for the primary key


database

t_role
------------
id_role (autoincrement)
login
password
typeRole(used to insert User or Group)

t_role_role
-----------------
idRoleRole (autoincrement)
idRoleFK1
idRoleFK2


t_role
id_Role / typeRole
-----------
1 user
2 user
3 group
4 group
5 user

t_role_role
iRoleRole / idRoleFK1 /idRoleFK2
--------------------
1 1 3
2 1 4
3 2
4 5 3

a user can have 0 or many group

t_role and t_role_role information

user 1 is a member of group 3 et 4
user 2 is not a member of any group
user 5 is a member of group 3

after readed hibernate document, i think i should use table per class hierarchy


it's my mapping file


i don't if i need to put in the subclass the one to many relation?
does i need to create another section in this file for t_role_role table?

help would be very appreciate...


thank

[ March 20, 2008: Message edited by: mark smith ]
[ March 20, 2008: Message edited by: mark smith ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic