Newbie in trouble, hope you can help.
At the moment I have two tables account and arrears_notice; there can be 0 or 1 rows on the arrears notice table.
Code:
<class
name="com.xxx.Account"
table="ACCOUNT"
>
<id
name="accountId"
type="java.lang.Long"
column="ACCOUNT_ID"
unsaved-value="0"
>
.......
<one-to-one name="arrearsNotice"
class="com.xxx.ArrearsNotice"
fetch="join"
lazy="no-proxy"
property-ref="account" />
......
</class>
<class name="com.xxx.ArrearsNotice" table="ARREARS_NOTICE" lazy="true" >
<id name="arrearsNoticeId" column="ARREARS_NOTICE_ID" unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_arrears_notice</param>
</generator>
</id>
<many-to-one name="account"
class="com.xxx.Account"
column="ACCOUNT_ID"
not-null="true"
lazy="no-proxy" />
......
</class>
I've now added an activeNotice column to the arrears notice table. There will only ever be one active notice row (active_notice = 1).
I want to change the mapping in the account table so that it only joins to the active row (or no row). As is, it falls over when there are multiple rows on the notice table. I don't want to change the mapping to a set, I'd like to leave it as a one-to-one.
I've tried several ways of doing this using 'formula' but am really struggling and would appreciate any help.
I'm using hibernate 3 and an Oracle database.