<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.lexiclan.orm.dao">
<class name="Address" table="ADDRESSES" lazy="false">
<id name="addressId" column="ADDRESS_ID">
<generator class="native" />
</id>
<many-to-one name="addressType" column="ADDRESS_TYPE_ID" not-null="true" class="AddressType" lazy="false" />
<many-to-one name="contact" column="CONTACT_ID" not-null="true" class="Contact" lazy="false" />
<property name="address1" column="ADDRESS_1" />
<property name="address2" column="ADDRESS_2" />
<property name="city" column="CITY" />
<property name="stateProvince" column="STATE_PROVINCE" />
<property name="zipPostalCode" column="ZIP_POSTAL_CODE" />
<property name="countryRegion" column="COUNTRY_REGION" />
</class>
</hibernate-mapping>
In this example, an address requires both a contact and an address type relationship before you can use "Session.save()" (which is what I want), but when I want to use "Session.delete()" I have to also specify a contact and address type relationship because of the not-null. Is there a way to require those values on save, but not on update/delete operations?