Hi there, I'm fairly new to hibernate but have so far managed quite well with mapping objects and pulling stuff from my mysql database.
I'm having trouble with a particular relationship in my model, I have a class called group and another called category, what I'm trying to achieve is one-to-many relationship so that one group can have many categories, the relation also needs to be bidirectional so I can pull the group from any given category.
Here is the relation in my mapping files, this one from category:
Code:
<many-to-one name="group" cascade="all" lazy="false" class="tracker.persistent.Group" not-null="true" foreign-key="fk_cat_group">
<column name="group_fk" />
</many-to-one>
And this one from group:
Code:
<set name="categories" table="t_category" lazy="false" cascade="all" inverse="true" >
<key column="group_fk"/>
<one-to-many class="tracker.persistent.Category" />
</set>
The relation works from category to group however when I execute the relation the other way (i.e. group.getCategories) I end up with a null set which I know from executing standard sql against the database is not the case.
I'm using mysql 5 with hibernate 3
Any help would be gratefully received,
Many thanks,
Oli