Hello
(Should this be filed as a hibernate bug, or am I just missing a configuration detail?)
Consider the following composite-element (relevant portions):
Code:
<hibernate-mapping>
<class name="model.util.ContactDetails" table="CONTACTDETAILS">
[... snip ...]
<set name="phoneSet" table="PHONES" lazy="false" cascade="all" sort="unsorted" outer-join="true">
<key column="CONTACTDETAILSID">
</key>
<composite-element class="model.util.Phone">
<property name="kind" type="java.lang.String" update="true" insert="true" column="KIND"/>
<property name="number" type="java.lang.String" update="true" insert="true" column="PHONENUMBER"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
When I update a PHONENUMBER, hibernate generates 2 SQL:
Code:
delete from PHONES where CONTACTDETAILSID=? and KIND=? and PHONENUMBER=?
insert into PHONES (CONTACTDETAILSID, KIND, PHONENUMBER) values (?, ?, ?)
Issue: PHONENUMBER is a nullable column. Before the update, the phone number is NULL, so the sql:
Code:
delete from PHONES where CONTACTDETAILSID=10 and KIND='B' and PHONENUMBER=null
does not delete anything!
The subsequent insert, throws a
Code:
ORA-00001: unique constraint (DEV6.PHONES_PK) violated
The question is: how can I get hibernate to generate
Code:
... where ... PHONENUMBER is null...
instead of
Code:
... where ... PHONENUMBER=null...
Any help / pointers will be highly appreicated.
Hibernate version: 3.1
Name and version of the database you are using: Oracle 10g
Thanks
Ajay