Embedded IDs Best Practice (MappedEntity vs ID) #2957
-
When creating an embedded id for a composite primary key should the fields that make up the embedded id be the raw values such as an Integer or UUID? Or should they be the full object/mapped entity in which they represent? For example, say we have a database setup consisting of an "account" table and a "club" table and there is a many to many relationship exists between theses two tables. Therefore we have a third table "club_member" which connects accounts and clubs as represented below.
So the question is what should the Embedded Id for this table look like out of the two options below? Option 1:
Option 2:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Depends if you want in some cases JOIN an account or a club entity. See examples: |
Beta Was this translation helpful? Give feedback.
Depends if you want in some cases JOIN an account or a club entity. See examples:
micronaut-data/data-tck/src/main/java/io/micronaut/data/tck/entities/ShipmentId.java
Line 26 in 25a7a06
micronaut-data/data-document-tck/src/main/java/io/micronaut/data/document/tck/entities/CountyPk.java
Line 23 in 25a7a06