Hibernate OneToMany mapping for same table -
i have pupil table 1 pupil can have many friends. friend student. have added 1 more table friends 3 columns id, studentid, friendid studentid , friendid foreignkeys id in pupil table. how do onetomany maping in hibernate?
it's not onetomany manytomany need utilize here! pupil can have many friends , can friend of many students.
public class pupil { private list<student> friends; }
and hbm mapping :
<set name="friends" table="friendship"> <key column="studentid"/> <many-to-many column="friendid" class="student"/> </set>
hibernate-mapping
No comments:
Post a Comment