Hibernate version:
3.0
Mapping documents:
not yet done
Name and version of the database you are using:
HSQL
The question is more conceptual question.
I have a simple class hierarchy - User has multiple Roles encapsulates multiple Permissions
Permissions are implemented as a child to java.security.Permission class. Every permission has its own class, so there classes like READ, EDIT, DELETE (children of my CommonPermission class)
I need to make Role instances persistent. The question is, how?
1. DB schema should be clear.
2. I'ts ok if permissions information will be lost as soon as row from Role table will be deleted
3. I would like as little Hibernate dependent code as possible
4. Ideal case whould be a separate table Permissions where with three rows (one for READ, EDIT and DELETE) and many-to-many association table
But the problem is that I have multiple classes with the same structure (i.e.
same field, different content hardcoded in the classes code).
Is it possible to map one-to-many to the custom type. For example
Table Roles:
-----------
ID | Name
1 Anonymous
2 Admin
3 Editor
Table Roles-To-Permissions
---------------
ROLE_ID | PERMISSION_VALUE
1 3
1 2
1 4
3 1
Table Permission (this table may not exists in simplest case)
---------------------
ID | Name
1 READ
2 EDIT
3 DELETE
4 RESTART
_________________ Br.
Renat
|