Embeddable properties in a subclass are ignored if they have the same name as superclass properties in Hibernate

Solution Verified - Updated -

Issue

  • An embeddable type has been defined.

    @Embeddable
    public class Contact ... {
        ...
        private String name;
        ...
    }
    
  • The embeddable is included in an entity which extends a superclass containing a property with the same name as an embeddable property.

    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    public abstract class Person ... {
    
        private String name;
        ...
    }
    
    @Entity
    public class Employee extends Person {
        ...
        @Embedded
        private Contact contact;
        ...
    }
    
  • The DDL and SQL generated by Hiberante omit the property (e.g. "name") so it does not exist in the generated schema / cannot be persisted or read.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content