You need to set your unsaved-value for the id mapping on both your Order and OrderItem. Currently, when you try to save your Order with OrderItem, it thinks that your OrderItem already exists in the DB and so attempts and update instead.
For example:
Order mapping file:
Code:
<class name="com.persistence.hibernate.Order" table="order1">
<id name="orderid" column="orderid" type="int" unsaved-value="0">
<generator class="increment"></generator>
</id>
....
OrderItem mapping file:Code:
<class name="com.persistence.hibernate.OrderItem" table="orderitem">
<id name="orderitemid" column="orderitemid" type="int" unsaved-value="0">
<generator class="increment"></generator>
</id>
....