I have a list inside a subclass mapped as follow:
Code:
<class
name="com.realtor.domain.user.Person"
table="person"
dynamic-update="true"
dynamic-insert="false"
discriminator-value="Person"
>
....
<subclass
name="com.realtor.domain.realestate.Agent"
dynamic-update="true"
dynamic-insert="true"
discriminator-value="agent"
>
<list
name="listings"
lazy="false"
inverse="false"
cascade="save-update"
>
<key
column="agent_id"
/>
<index
column="agent_listing_idx"
/>
<many-to-many
class="com.realtor.domain.realestate.Listing"
column="listing_id"
outer-join="auto"
/>
</list>
...
</subclass>
Inside Listing's mappingCode:
<many-to-one
name="agent"
class="com.realtor.domain.realestate.Agent"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="agent_id"
/>
When I add listings to the Agent's listings List The listings table in the database is not updated but the foreign keys are set correctly in the
listing table.
The listings schema is
listing_id agent_id agent_listing_idx
This table (listing
s) is not updated
The listing schema has an agent_id as a foreign key that get updated when I insert into the collection.
FOREIGN KEY (agent_id) REFERENCES person(id)
I often use this mapping with no problem the only difference this time is that it's inside a subclass.