In my database I have a table with a primary key, id, and a set of fields one of which is a varchar field named username. A second table has two varchar fields username, authority as a composite primary key. username from the first table is used to match username in the second table to retrieve multiple values for authority. In my hibernate mapping file I have the following:
Code:
<id name="id" column="id">
<generator class="native" />
</id>
<property name="username" />
<!-- more properties... -->
<set name="authorities" table="authorities">
<key column="username" foreign-key="username"
<element column="authority" type="string" />
</set>
I ran a test with this mapping and the result is that the value from the id field of the first table gets inserted into the username field of the second table. What I need is for the value of the username field of the first table to be inserted into the second table.