code: public void setKeyMetadata(KeyMetadata keyMetadata) {
      if (this.keyMetadata != null) {
        String format = "Class %s has two fields, %s and %s marked with %s annotation. Only one "
            + "field can be marked as Key. ";
        String message = String.format(format, entityClass.getName(), this.keyMetadata.getName(),
            keyMetadata.getName(), Key.class.getName());
        throw new EntityManagerException(message);
  
      }
      this.keyMetadata = keyMetadata;
    }
docs: Sets the metadata of the Key field.
  
  @param keyMetadata
  the key metadata.