Lazy properties are not updated if not all lazy properties are initialized

Description

I have instrumented entity class with 2 lazy properties and @ManyToMany lazy association:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @Entity public class HkvSubclass { @Lob @Basic(fetch = FetchType.LAZY) @Column(name = "CERTIFICATE_1") private String encodedCertificate1; @Lob @Basic(fetch = FetchType.LAZY) @Column(name = "CERTIFICATE_2") private String encodedCertificate2; @ManyToMany(mappedBy = "hkvSubclasses", cascade = CascadeType.ALL) @Fetch(FetchMode.SUBSELECT) private List<HkvDocument> hkvDocuments = new ArrayList<>(0); // other properties...

If I update any lazy property (encodedCertificate1 or encodedCertificate2), Hibernate does not update it to database - it executes UPDATE, but without including the column(s) of updated property.

Update occurs only if I initialize all lazy properties: encodedCertificate1, encodedCertificate2 and hkvDocuments.

The culprit seems to be in AbstractEntityPersister#update method where it gets SQL update statements from getUpdateStrings() method (and accordingly the property list to use from method getPropertyUpdateability()) based on whether all lazy properties were initialized.

Environment

Java 8, Oracle 10g

Status

Assignee

Gail Badner

Reporter

Petras

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.0

Priority

Major