JPA/Hibernate – Embedding a Composite Primary Key (@Embeddable, @EmbeddedId)
JPA/Hibernate – Embedding a Composite Primary Key (@Embeddable, @EmbeddedId)
In this example, we will learn how to embed a composite primary key, we will declare the IDs (primary key fields) as a separate class annotated with the @Embeddable annotation.A student is identified by its StudentCompositeId, which is defined by eleveId and class.