use the one-to-many or many-to-one
Two class: Department Task One department can have many tasks. One task can only belong to one department. So use one-to-many or many-to-one? one-to-many class Department{ private Set tasks; } class Task{ ...... } // Department.hbm.xml .... <set name="tasks"> <key column="departId" /> <one-to-many class="Task" /> </set> ..... many-to-one class Department{ } class Task{ Department depart; } // Task.hbm.xml .... <property name="depart"> <many-to-one class="Department" /> </property> ..... What's the difference? BTW,what is the difference between use the set and list? And example using list(xml