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

Metamodel does not include embeddable type used in type variables

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.8
    • Fix Version/s: 5.2.9
    • Component/s: hibernate-core
    • Labels:
      None

      Description

      This is a kind of a follow up because HHH-10690 Open actually is part of the reason for this problem. Embeddable types that only ever get used in a type variable are not picked up by the JPA metamodel implementation. Let's take a look at the following example

      @MappedSuperclass
      public class BaseEntity<T extends Serializable> {
        @EmbeddedId
        private T id;
      }
      
      @Embeddable
      public class MyEntityId implements Serializable {
        private String someValue;
      }
      
      @Entity
      public class MyEntity extends BaseEntity<MyEntityId> {
      }
      

      The type MyEntityId will not be available via metamodel.managedType(MyEntityId.class) because currently, Hibernate only adds types to the type registry that are either root types or the types of attributes. Since the attribute id in this case has the type bound as attribute type i.e. java.io.Serializable there is no managed type instance created for the real type MyEntityId.
      Instead a managed type instance for java.io.Serializable is created which is obviously wrong. There should be no manage type instance for java.io.Serializable but only for MyEntityId.

        Attachments

          Activity

            People

            • Assignee:
              christian.beikov Christian Beikov
              Reporter:
              christian.beikov Christian Beikov
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: