Hi,
I have a one-to-many one directional relation:
Product 1-------->* ProductAttribut
in my code i made :
Product pd = new Product(pk,"CU");
ProductAttribut pa = new ProductAttribut(.....);
pd.addProductAttribute(pa);
session.saveOrUpdate(pd);
session.flush();
session.connection().commit();
on the console i see
insert into PRODUCTS (LN_SUPPLIER, ........
update PRODUCT_ATTRIBUTES set DT_UPDATE=?,
So the product it's added but not the ProductAttribute
What do i have to do to see un insert into produt_attriutes ?
i would like to see something like that
insert into PRODUCTS (LN_SUPPLIER, ........
INSERT INTO PRODUCT_ATTRIBUTES.....
update PRODUCT_ATTRIBUTES set DT_UPDATE=?,...
Here are the mapping files:
Product
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.influe.asp.product.hibernate.Product"
table="PRODUCTS"
>
<composite-id name="comp_id" class="com.influe.asp.product.hibernate.ProductPK">
<key-property name="LN" column="LN" type="java.lang.String"/>
<key-property name="NC_LN_COD_TYP" column="NC_LN_COD_TYP" type="java.lang.String"/>
<key-property name="PN" column="PN" type="java.lang.String"/>
<key-property name="NC_PN_COD_TYP" column="NC_PN_COD_TYP" type="java.lang.String"/>
<key-property name="PV" column="PV" type="java.lang.String"/>
</composite-id>
<property
name="LN_SUPPLIER"
type="java.lang.String"
column="LN_SUPPLIER"
length="20"
/>
<!-- one-directional one-to-many association to ProductAttribut -->
<set
name="productAttributs"
lazy="true"
inverse="true"
cascade = "all"
>
<key>
<column name="LN" />
<column name="NC_LN_COD_TYP" />
<column name="PN" />
<column name="NC_PN_COD_TYP" />
<column name="PV" />
</key>
<one-to-many
class="com.influe.asp.product.hibernate.ProductAttribut"
/>
</set>
</class>
</hibernate-mapping>
ProductAttribute XML
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.influe.asp.product.hibernate.ProductAttribut"
table="PRODUCT_ATTRIBUTES"
>
<composite-id name="comp_id" class="com.influe.asp.product.hibernate.ProductAttributPK">
<key-property name="FIELD" column="FIELD" type="java.lang.String"/>
<key-property name="LN" column="LN" type="java.lang.String"/>
<key-property name="NC_LN_COD_TYP" column="NC_LN_COD_TYP" type="java.lang.String"/>
<key-property name="PN" column="PN" type="java.lang.String"/>
<key-property name="NC_PN_COD_TYP" column="NC_PN_COD_TYP" type="java.lang.String"/>
<key-property name="PV" column="PV" type="java.lang.String"/>
</composite-id>
<property
name="DT_UPDATE"
type="java.sql.Timestamp"
column="DT_UPDATE"
not-null="true"
length="7"
</class>
</hibernate-mapping>
Here are the java files:
Product.java
Thank's a lot
Ady
|