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

Fix for HHH-9864 causes "MappingException: collection was not an association" with hibernate.order_inserts=true and component association

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 5.2.4
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Requires Release Note:
      Affirmative
    • Last commented by a user?:
      true
    • Sprint:

      Description

      After upgrading to 5.2.4 we started getting weird "org.hibernate.MappingException: collection was not an association: com.renxo.cms.domain.network.ShortCode.localizedFields" when saving new entity instances for some of our mapped classes. Previously we were running 5.2.3 without any issues.

      The property in question is mapped like this:

      @Override
      @Audited
      @AuditJoinTable(name = "short_code_locale_aud")
      @MapKeyType(value = @Type(type = "locale"))
      @MapKeyClass(LocaleType.class)
      @ElementCollection(fetch = FetchType.EAGER)
      @CollectionTable(name = "short_code_locale", joinColumns = @JoinColumn(name = "short_code_id", nullable = false, foreignKey = @ForeignKey(name = "sh_code_sh_code_loc_fk")))
      @MapKeyColumn(name = "locale", length = 12, nullable = false)
      @BatchSize(size = 100)
      @Fetch(FetchMode.SELECT)
      @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
      public Map<Locale, LocalizedFields> getLocalizedFields()

      { return localizedFields; }

      See the attached stack trace. This seems likely related to the changes introduced by HHH-9864 Closed at org.hibernate.engine.spi.ActionQueue$InsertActionSorter.addParentChildEntityNames() which seems to be assuming that all inserts are related to entity names without considering that inserts may also be cause by component collections, such as our case.

      In the meantime, we're working around this issue by disabling hibernate.order_inserts in hibernate.properties

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: