Using: hibernate-core-3.3.2.GA.jar
I'd like to map a legacy relation using a group of properties, where one of the property values is null.
I have a class mapping like this, where the director relation is optional:
Code:
<class name="Process" table="process" lazy="true">
<id name="id" type="java.lang.Long" column="processId" unsaved-value="null">
<generator class="native"/>
</id>
<version name="lastModified" type="timestamp"/>
<properties name="ownerStatusDirector">
<many-to-one name="owner" class="Person" column="ownerId" insert="true" update="false"/>
<property name="statusCode" type="java.lang.String"/>
<many-to-one name="director" class="Person" column="directorId" insert="true" update="false"/>
</properties>
. . .
</class>
I'd then like to have a person mapping with a one-to-one relation to their active process, where director is null.
Code:
<class name="Person" table="person" lazy="true">
<id name="id" type="java.lang.Long" column="personId" unsaved-value="null">
<generator class="native" />
</id>
<version name="lastModified" type="timestamp"/>
. . .
<one-to-one name="activeDirectorlessProcess" outer-join="false" foreign-key="ownerId"
property-ref="ownerStatusDirector" lazy="proxy" cascade="all">
<formula>ownerId</formula>
<formula>'A'</formula>
<formula>null</formula>
</one-to-one>
. . .
</class>
This generates the following SQL:
Code:
. . .
where process0_.ownerId=7103 and process0_.status='A' and process0_.directorId=null
Obviously, "=null" will not work, and instead I need "is null". Can someone point me in the right direction to map this?