Skip to content

Latest commit

 

History

History

HibernateSpringBootCompositeKeyEmbeddableMapRel

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

How To Define A Composite Primary Key Via @Embeddable

Description: This application is a proof of concept of how to define a composite key via @Embeddable and @EmbeddedId. This application uses two entities, Author and Book involved in a lazy bidirectional @OneToMany relationship. The identifier of Author is composed by name and age via AuthorId class. The identifier of Book is just a typical auto-generated numeric value.

Key points:
- The composite key class (e.g., AuthorId) is public
- The composite key class must implement Serializable
- The composite key must define equals() and hashCode()
- The composite key must define a no-arguments constructor