Uploaded image for project: 'Hibernate ORM'
  1. HHH-10866

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 5.2.0
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
    • Environment:
      Java 8, Oracle 10g
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

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

      @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.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: