I just tried to do the composite-id method and I get an error. Apparently I can't use one of the fields specified in the composite-id for anything other than the composite-id. So this didn't work:
Code:
<class name="com.company.Authority" table="Authorities">
<composite-id>
<key-property name="username" column="Username"/>
<key-property name="authority" column="Authority"/>
</composite-id>
<!--<property name="authority" column="Authority" length="255"/>-->
<many-to-one name="user" class="com.company.User" column="Username"/>
</class>
I had tried commenting out the authority property, but the many-to-one relationship uses the same column as in the first key-property. If I take that out, then I don't get my many-to-one relationship.