It seems I haven't been very clear. I already store my objects correctly, but need to change something to them when they're in a group. This is my group mapping file, which has to be changed:
Code:
<hibernate-mapping>
<class name="project.beer.group.Group" table="groups" lazy="false">
<id name="id" column="group_id">
<generator class="increment"/>
</id>
<set name="grolsches" table="grolsches">
<key column="gr_group_id"/>
<one-to-many class="project.beer.grolsch.Grolsch"/>
</set>
<set name="heinekens" table="heinekens">
<key column="he_group_id"/>
<one-to-many class="project.beer.heineken.Heineken"/>
</set> </class>
</hibernate-mapping>
As you can see I have a java class "Group" with a set of Grolsch objects and a set of Heineken objects.
I want them in one set with "Beer" objects (they extend the Beer class), but in that case I will have to seperate them in the mapping file I guess? (because they change something in different tables) How can I do so?
(I do not prefer the workaround : making a "groupId" in the Group.java)