posted 20 years ago
Again as per the spec:
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:
<!ELEMENT entity(description?, display-name?, small-icon?, large-icon?, ejb-name, home, remote, ejb-class, persistence-type, prim-key-class, reentrant, cmp-filed*, primkey-field?, env-entry*, ejb-ref*, security-role-ref*, resource-ref*)>
As per the above DTD entry prim-key-class is mandatory for entity beans and primkey-field is optional.