Inherited IdClass properties ignored in Hibernate

Solution Verified - Updated -

Issue

  • Defined an id class hierarchy for use with an entity with a composite id

    public class KeyWithName ... {
        private String name;
        ...
    }
    
    public class KeyWithNameAndId extends KeyWithName ... {
        private Long id;
        ...
    }
    
    @Entity
    @IdClass(KeyWithNameAndId.class)
    public class MyEntity {
        @Id
        private String name;
        @Id
        private Long id;
        ...
    }
    
  • The properties of the superclass (e.g. KeyWithName) are ignored
    • They are omitted from DDL when Hibernate creates the table
    • They are not included when the entity is persisted to the database
    • They are not included in the WHERE clause of finds

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