The most compelling reason to use composite key is to implement the
KeyedEntity trait (and enable it’s functionality). It also has the
advantage of documenting the fact that fields/columns form a composite
key. Another benefit is that equality expressions can be shortened.
Consider the following example where CourseAssignment is a
CourseAssignment.id is a unique identifier for a CourseAssignment. In
this case id is what makes the class a
KeyedEntity[CompositeKey2[Long,Long]]. A class can have any number
of composite keys, a composite key is not necessarily a primary key.
A composite key can be used in any equality expression (x === y),
composite key or a tuple that is compatible, i.e. that has the same type
Note CompositeKeys cannot be used as binding expressions in
relations (see : issue