We're updating the issue view to help you get more done. 

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

Description

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"

Environment

None

Status

Assignee

Brett Meyer

Reporter

Aaron Trewern

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

3.5.2

Priority

Major