I have a many-to-many relationship in the db but the domain models it as a many-to-one. Is there anyway to map the relationship as a many-to-one, so that I end up with multiple instances of countysurvey (one for each marketsegment)?
I'm using Hibernate 2.1 against an oracle 9i db.
Thanks,
Tim
Code:
<class name="MarketSegment" table="GDR_PROD.MKT_SEG">
<jcs-cache usage="read-only"/>
<id name="id" type="long" column="MKT_SEG_GNMBR">
<generator class="assigned"/>
</id>
<set name="countySurveys" table="GDR_PROD.MKT_SEG_SMPL_GEO" lazy="false">
<key column="MS_MKT_SEG_GNMBR"/>
<many-to-many column="SG_SMPL_GEO_GNMBR" class="CountySurvey"/>
</set>
</class>
<class name="CountySurvey" table="GDR_PROD.SMPL_GEO">
<jcs-cache usage="read-only"/>
<id name="id" type="int" column="SMPL_GEO_GNMBR">
<generator class="assigned"/>
</id>
<property name="name" column="SMPL_GEO_NAME"/>
<set name="marketSegments" table="GDR_PROD.MKT_SEG_SMPL_GEO" lazy="false">
<key column="SG_SMPL_GEO_GNMBR"/>
<many-to-many column="MS_MKT_SEG_GNMBR" class="MarketSegment"/>
</set>
</class>