Thanks for reply. Here are my mapping files. I've supplied them before but never got any responses so I'm posting them again based on the feedback in the previous message. Given this mapping, no rows get inserted into my link_customer_address table when I insert a Customer that has an Address. The customer and address tables are populated with a single row each.
Here is the mapping for my customer table (customer.hbm.xml)
FYI...the link_customer_address table defines two columns,
customer_id
address_id
the primary key is a composite of the two columns and I've defined two FK relationships back to each of the respective related tables (customer, address).
<hibernate-mapping>
<class name="com.receptrix.hibernate.Customer" table="customer" catalog="reservation">
<id name="id" type="java.lang.Long">
<column name="id" />
<generator class="native" />
</id>
<property name="lastName" type="java.lang.String">
<column name="last_name" length="50" not-null="true" />
</property>
<property name="firstName" type="java.lang.String">
<column name="first_name" length="50" not-null="true" />
</property>
<property name="middleInitial" type="java.lang.String">
<column name="middle_initial" length="1" />
</property>
<property name="suffix" type="java.lang.String">
<column name="suffix" length="5" />
</property>
<property name="phone" type="java.lang.String">
<column name="phone" length="13" />
</property>
<property name="phoneType" type="java.lang.String">
<column name="phone_type" length="10" />
</property>
<property name="emailAddress" type="java.lang.String">
<column name="email_address" length="100"/>
</property>
<set name="addresses" table="link_customer_address" cascade="save-update">
<key column="customer_id"/>
<many-to-many class="com.receptrix.hibernate.Address" column="address_id"/>
</set>
</class>
</hibernate-mapping>
****** address table mapping **********
<hibernate-mapping>
<class name="com.receptrix.hibernate.Address" table="address" catalog="reservation">
<id name="id" type="java.lang.Long">
<column name="id" />
<generator class="native" />
</id>
<property name="addressLine1" type="java.lang.String">
<column name="address_line_1" length="100" not-null="true" />
</property>
<property name="addressLine2" type="java.lang.String">
<column name="address_line_2" length="100" />
</property>
<property name="city" type="java.lang.String">
<column name="city" length="50" not-null="true" />
</property>
<property name="stateProvince" type="java.lang.String">
<column name="state_province" length="50" not-null="true" />
</property>
<property name="countryCode" type="java.lang.String">
<column name="country_code" length="2" not-null="true" />
</property>
<property name="zipCode" type="java.lang.String">
<column name="zip_code" length="5" not-null="true" />
</property>
<property name="zipExtension" type="java.lang.String">
<column name="zip_extension" length="4" />
</property>
</class>
</hibernate-mapping>
Regards,
J.D.
|