Hi,
I'm trying store a Vehicle with a newly created LicensePlate using a many-to-many relationship. Here is the mapping (simplified):
Code:
<class name="Vehicle"
table="vehicle">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">vehicle_id_seq</param>
</generator>
</id>
<bag name="licensePlates" table="license_plate_to_vehicle" lazy="true"
cascade="all-delete-orphan" inverse="true">
<key column="vehicle_id"/>
<many-to-many column="license_plate_id" class="LicensePlate" />
</bag>
</class>
<class name="LicensePlate"
table="license_plate">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">license_plate_id_seq</param>
</generator>
</id>
<property name="number" column="number" />
<many-to-one name="locationOfRegistration" column="state_province_id"
class="StateProvince" />
<property name="isActive" column="is_active" />
</class>
When I add a new LicensePlate to Vehicle and store, it is storing the LicensePlate (here's the debug sql):
Code:
insert into license_plate (number, state_province_id, is_active, id) values (?, ?, ?, ?)
But, it is
NOT storing the license_plate_to_vehicle relationship. I know this is a simple many-to-many and I'm not sure I'm missing something obvious. Can you see what? Any ideas?