Hello All,
I'm very new to Hibernate and have tried various mappings to get a User object containing its role (already in User table) and the user's set of functions (role_function.fk_function) given the table definitions below. Both User and Fcn contain a foreign key into the Role table. How would the mappings look for these tables to get the function values loaded into the User object as a Collection of Integers?
Is the User/Role relationship considered many-to-one?
Is the Role/Fcn relationship considered one-to-many?
Is the User/Fcn relationship considered many-to-many?
Is there a way to make this happen in a single operation or does it have to be split into two steps?
Thanks, Gary
Is this on the right track?
<class name="User" table="USER">
<id name="pkUser" type="integer" column="PK_USER">
...
</id>
<property
column="FK_ROLE"
length="9"
name="fkRole"
not-null="true"
type="integer"
/>
<array name="fcns" table="USER">
<key column="FK_ROLE"/> <--User table FK column to use
<index column="I"/>
<many-to-many column="FK_ROLE" class="Fcn"/> <--Fcn table FK column to use
</array>
</class>
CREATE TABLE user (
pk_user number(9) not null primary key,
...
...
...
fk_role number(9) not null,
);
CREATE TABLE role (
pk_role number(9) not null primary key,
...
);
CREATE TABLE role_function (
pk_role_function number(9) not null primary key,
fk_role number(9) not null,
fk_function number(9) not null
);
[/b]
|