Consider these two classes mapped to the same table. One is readonly via mutable="false".
<class name="Funder" table="funder">
<id name="id">
<generator class="identity" />
</id>
<property name="funder_name" />
<property name="contact_name" />
<property name="addr_line_1" />
<property name="addr_line_2" />
<property name="addr_line_3" />
<property name="city" />
<many-to-one name="state" column="state_id" foreign-key="FK_funder_state_id" fetch="join" />
<property name="zip_code" length="10" />
<property name="phone_number" length="30" />
<property name="create_dt" update="false" not-null="true" />
<many-to-one name="create_by" column="create_by" not-null="true" update="false" foreign-key="FK_funder_create_by" fetch="join" />
<property name="last_update_dt" insert="false" />
<many-to-one name="last_update_by" insert="false" foreign-key="FK_funder_last_update_by" fetch="join" />
</class>
<class name="FunderSimple" table="funder" schema-action="none" mutable="false">
<id name="id">
<generator class="identity" />
</id>
<property name="funder_name" />
<property name="contact_name" />
<property name="phone_number" />
</class>
If I move the FunderSimple mapping before the Funder mapping my schema does not generate correctly. If I leave it as is above, it works.
Is this by design? It seems as though the schema-action="none" sticks to the table_name and later mappings to the same table will not generate the schema.
I'm doing it like this because I have another class named Contract which has a foreign key to the funder table. However, I don't need all the funder columns when referencing from the contract object.
<many-to-one name="funder_simple" column="funder_id" foreign-key="FK_contract_funder_id" fetch="join" />
Funder does not inherit from FunderSimple.
Should I be using a different technique to fetch only a subset of columns from a foreign key table? Is many-to-one the only way to setup a foreign key?
using version 2.1.0.4000