This is what i have:
Companies (id, name,...)
persons (id, name,....)
functions (id,description)
company_person(id,com_id,prs_id,fun_id)
i want to use this in my jsf application but having problems modeling it...
I want the company to have a methode wherei get all the persons with there function in that company. This is what i have so far:
Code:
<hibernate-mapping>
<class name="Company" table="companies">
<id name="id">
<generator class="identity"/>
</id>
<set name="persons" table="company_person">
<key column="com_id"/>
<many-to-many class="Person" column="prs_id"/>
</set>
</class>
</hibernate-mapping>
Here is the problem... i guess when i fetch the set of persons, i don't have the functions...
My person file is like this:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Person" table="persons">
<id name="id">
<generator class="identity"/>
</id>
<property name="name"/>
</class>
</hibernate-mapping>
As you can see, a person don't know what function he is because he can be part of more than one company and have a different function in a different company.
So.. i do i tell hibernate this and in what file do i have to define the relation between function and person. and how...
My function file is like this:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Function" table="functions">
<id name="id">
<generator class="identity"/>
</id>
<property name="description"/>
</class>
</hibernate-mapping>