the relatioinship is bidirectional, and there are 2 types of contracts that a client can have with a single bank, so, in the table contracts, i need a 3rd column contractType, but in the map file, a can't do this.
i need to add a property tag, (
contractType)
Code:
<class name=Company table=company>
....
<subclass name="Client" discriminator-value="CLIENT">
.....
<many-to-one name="company"
class="Company"
access="property"
cascade="none"
outer-join="false"
foreign-key="id_company_fk">
<column name="id_company_parent" not-null="false" unique-key="unique_company_per_level"/>
</many-to-one>
<!-- this is what i was talking about, the table resulting from this map file looks crazy, and i dont know if its ok, -->
<set name="companyChilds"
cascade="all-delete-orphan"
inverse="true"
lazy="true"
batch-size="10">
<key column="id_company_father"/>
<one-to-many class="Company"/>
</set>
.......
<set name="banks"
table="contracts"
lazy="true"
inverse="true"
cascade="save-update">
<key column="client_id"/>
<many-to-many class="Client" column="bank_id"/>
</set>
</subclass>
<subclass name="Bank" discriminator-value="BANK">
....
<set name="clients"
table="contracts"
lazy="true"
cascade="save-update">
<key column="bank_id"/>
<many-to-many class="Bank" column="client_id"/>
</set>
</subclass>
</Class>
the property tag for contract type must be into the set, but i can't, is there other way. Should i make a 3rd class?, Contract and map it to a table, and then make the relation many-to-one collection between Contract and Bank, and Contract and Client.