hi
i'm a newbie with hibernate 3, 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
Code:
<hibernate-mapping>
<class name="test.Role" table="t_role">
<id name="id" type="long" column="idRole">
<generator class="increment"/>
</id>
<discriminator column="typeRole" type="string"/>
<subclass name="test.User" discriminator-value="User">
<property name="login" column="login"/>
<property name="password" column="password"/>
</subclass>
<subclass name="test.Group" discriminator-value="Group">
</subclass>
</class>
</hibernate-mapping>
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