Hi,
I need some help regarding a special requirement I have for a many-to-many link table.
I have two tables: CATEGORY and TECHNOLOGY which have many-to-many relationship. The mapping files specify the reference (link) table as 'technology_category'
The section of the mapping file (technology.hbm.xml) is shown below:
Code:
<set name="categories" table="technology_category" cascade="save-update" lazy="true" >
<key column="technology_id" not-null="true" />
<many-to-many class="Category" column="category_id"/>
</set>
The section of the mapping file (category.hbm.xml) is shown below:
Code:
<set name="technologies" table="technology_category" inverse="true" cascade="save-update" lazy="true" >
<key column="category_id" not-null="true" />
<many-to-many class="Technology" column="technology_id"/>
</set>
Example values in CATEGORY table are similar to FRAMEWORK, TOOL, IDE etc.
Example values in TECHNOLOGY table are HIBERNATE, ECLIPSE etc.
I have no issues in presisting / retrieving the data from any of these tables.
ISSUE:
when Hibernate writes to the link table (CATEGORY_TECHNOLOGY), I want to write other details such as user_id etc, which is available in the web layer.
Here is what I want in the link table.
category_id, technology_id, user_id
How do I go about doing it?
The mapping only allows only IDs from the participating tables.
Thanks