In the 4.1.8 reference manual and in the section 1.2.4, the email table has a composite primary key of both the person id and email fields. Irrespective of how Hibernate works, as a design decision this would be wrong. It is also mentioned that because a composite key is used, duplicate emails per user are avoided. This would be achieved anyway if the primary key was just the email address field itself. What you achieve by using a composite key is the possibility of two different users sharing the same email address.
By the way, I ran the example against a MySQL database and the table was created with no primary key specified. (The person-event relationship table was created with a composite key).
|