[hibernate-issues] [Hibernate-JIRA] Created: (HHH-7072) ElementCollection not updated correctly if the Embeddable component has a nullable property

Aaron Trewern (JIRA) noreply at atlassian.com
Wed Feb 15 11:35:09 EST 2012


ElementCollection not updated correctly if the Embeddable component has a nullable property
-------------------------------------------------------------------------------------------

                 Key: HHH-7072
                 URL: https://hibernate.onjira.com/browse/HHH-7072
             Project: Hibernate ORM
          Issue Type: Bug
          Components: annotations
    Affects Versions: 3.5.2
            Reporter: Aaron Trewern


I have an @ElementCollection that is a collection of @Embeddable components. When saving an updated entity I can see that Hibernate issues an SQL DELETE for each of the rows in the collection followed by an INSERT, as is expected behaviour for an @ElementCollection.

The rows are deleted using a where clause that includes all the properties of the @Embeddabkle component. With MySQL the DELETE fails to delete any rows where the property is a nullable property and the previous value was null.

This is because Hibernate issues a prepared SQL ststement like "DELETE FROM tableName t where t.a = ? and t.b = ?" now if b is a nullable property and the component being saved has a null value for b then the delete will fail.

To correctly delete the row with MySQL the statement should be "DELETE FROM tableName t where t.a = ? and t.b is null"

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list