Hi all,
I need a helping hand on this one.
Consider this mapping, based on these 2 very classic entities :
Code:
<class name="Order" table="ORDERS" >
<id name="id" column="ORDER_ID" type="long">
<generator class="sequence">
<param name="sequence">ORDER_ID_SEQ</param>
</generator>
</id>
<!-- bidirectional one-to-many Order>Product -->
<set name="products" inverse="true" cascade="save-update" >
<key column="ORDER_ID" not-null="true" />
<one-to-many class="Product" />
</set>
...
</class>
...
<class name="Product" table="PRODUCTS" >
<composite-id name="id" class="ProductId" >
<key-property name="orderId" column="ORDER_ID" type="long" />
<key-property name="productId" column="PRODUCT_ID" type="long" />
</composite-id>
<!-- bidirectional one-to-many Order>Product -->
<many-to-one name="order" column="ORDER_ID" insert="false" update="false" not-null="true" />
...
</class>
(following these indications:
http://www.hibernate.org/117.html#A34)
But, sadly, I can't get this to work... When I try to save an Order with its linked products (by cascade), Hibernate does not seem to be able to set the correct generated ORDER_ID :
Code:
GRAVE: ORA-01400: cannot insert NULL into ("xx"."PRODUCTS"."ORDER_ID")