Hi,
I have a one-to-one relationship using a unidirectional many-to-one w/FK constraint mapping and I was wondering if I can allow null values for the FK. For example, I have a one-to-one relationship between Customer and Account (where Customer knows Account but not vice-versa). Sometimes the business rule allows a Customer to exist without an Account (for accounts pending) so I need the flexibility of having null values for accountIds in the customer table. How can I allow this null value on the FK. The way I have it set up now, I get a FK constraint... below is my mapping:
Code:
<hibernate-mapping>
<class
name="com.test.domain.Customer"
table="CUSTOMER">
<id name="customerId" type="long">
<column name="CUSTOMER_ID" not-null="true"/>
<generator class="native"/>
</id>
.....
<many-to-one
name="account"
class="com.test.domain.Account"
column="ACCOUNT_ID"
cascade="all"
unique="true"/>
</class>
</hibernate-mapping>