|
Hi all,
I have a mapper table in many-to-many mapping that maps contacts to office.
This mapper table has some state columns (like date registered, position, active....) that belongs really to Contact class.
So I thought to I would map all these columns into my Contact class.
But I am having serious problems.
Instead of giving you my whole mappings (which I can do), I'll only paste the most important part:
<class name="MyContact" table="tblContact">
<id name="contactId" column="ContactID">
<generator class="identity" />
</id>
<property name="name" column="FirstName" />
<property name="lastName" column="LastName" />
<property name="password" column="Password" />
<set name="offices" table="tblAccount" cascade="save-update">
<key column="ContactID" />
<many-to-many column="OfficeID" class="MyOffice" />
</set>
<join table="tblAccount" fetch="join">
<key column="ContactID" not-null="true" />
<property name="position" column="Position" />
<property name="active" column="Active" />
</join>
</class>
What happens is hibernate tries to insert record into tblAccount with "insert into tblAccount (Position, Active, ContactID)". It is missing OfficeID!
I guess this makes sense, but I don't know how to change avoid it.
Any hints, even one word ones will be very welcome.
Anonchi
|