I am using MySql 4.0.15-max-nt in Windows XP.
When I create the mapping many-to-one association from Order -> Item
I want it is not allowed to execute ( eg. throw an exception )
Code:
session.delete(order) // remove the order by hibernate API
when Order have one or more Item.
Currently, I can delete the Order even there is Item assoicaite with it.
Code:
// xml in Item
<many-to-one name="purchaseOrder"
class="hibernate.PurchaseOrder"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="purchaseOrder"/>
Code:
// xml in Order
<bag name="purchaseItems"
lazy="false"
inverse="false"
cascade="none">
<key column="purchaseOrder"/>
<one-to-many class="hibernate.PurchaseItem"/>
</bag>
The xml is genereted by Xdoclet