I have 3 tables: users, user_types, and logs. I want to create multiple many-to-many mapping from logs to users where each set has a unique user_type (and I don't care about logs from the users perspective).
So, in logs.hbm.xml, I have:
Code:
<set name="inputPrepUsers" table="users" cascade="all" lazy="false">
<key column="log_id"/>
<many-to-many column="user_id" class="com.mydomain.core.model.User"/>
</set>
<set name="preQcUsers" table="users" cascade="all" lazy="false">
<key column="log_id"/>
<many-to-many column="user_id" class="com.mydomain.core.model.User"/>
</set>
<set name="reRunPrepUsers" table="users" cascade="all" lazy="false">
<key column="log_id"/>
<many-to-many column="user_id" class="com.mydomain.core.model.User" where=""/>
</set>
<set name="outputPrepUsers" table="users" cascade="all" lazy="false">
<key column="log_id"/>
<many-to-many column="user_id" class="com.mydomain.core.model.User"/>
</set>
<set name="postQcUsers" table="users" cascade="all" lazy="false">
<key column="log_id"/>
<many-to-many column="user_id" class="com.mydomain.core.model.User"/>
</set>
What I need to know is how to filter each set based on a specific user_type_id. I could just use the where attribute on the many-to-many element, but was wondering if there was a more dynamic way.
Thanks!