This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Just a doubt about the Composite Primary Key. Sure one has to create a Primary key class and put that in <prim-key-class> tag. But what about <primkey-field>? Do we need to have multiple <primkey-field> for each <cmp-field> which is part of the Primary Key?
Also do we need to make sure that the Primary key class instance variables are named as they appear in <cmp-field>?
The prim-key-class element contains the fully-qualified name of an entity bean's primary key class.
The primkey-field element is used to specify the name of the primary key field for an entity with container-managed persistence.
The primkey-field must be one of the fields declared in the cmp-field element, and the type of field must be the same as the primary key type.
The primkey-field element is not used if the primary key maps to multiple container-managed fields (i.e., the key is a compound key). In this case, the fields of the primary key class must be public, and their names must correspond to the field names of the entity bean class that comprise the key.
So we need not have multiple <primkey-field> for each <cmp-field> which is part of the Primary Key. Hence ur second question not applies.
The following is the DTD entry of DD corresponding to entity element: