private <X> void applyIdMetadata(
     PersistentClass persistentClass, EntityTypeImpl<X> jpaEntityType) {
   if (persistentClass.hasIdentifierProperty()) {
     final Property declaredIdentifierProperty = persistentClass.getDeclaredIdentifierProperty();
     if (declaredIdentifierProperty != null) {
       jpaEntityType
           .getBuilder()
           .applyIdAttribute(
               attributeFactory.buildIdAttribute(jpaEntityType, declaredIdentifierProperty));
     }
   } else if (persistentClass.hasIdentifierMapper()) {
     @SuppressWarnings("unchecked")
     Iterator<Property> propertyIterator =
         persistentClass.getIdentifierMapper().getPropertyIterator();
     Set<SingularAttribute<? super X, ?>> attributes =
         buildIdClassAttributes(jpaEntityType, propertyIterator);
     jpaEntityType.getBuilder().applyIdClassAttributes(attributes);
   } else {
     final KeyValue value = persistentClass.getIdentifier();
     if (value instanceof Component) {
       final Component component = (Component) value;
       if (component.getPropertySpan() > 1) {
         // FIXME we are an Hibernate embedded id (ie not type)
       } else {
         // FIXME take care of declared vs non declared property
         jpaEntityType
             .getBuilder()
             .applyIdAttribute(
                 attributeFactory.buildIdAttribute(
                     jpaEntityType, (Property) component.getPropertyIterator().next()));
       }
     }
   }
 }
  /**
   * Generates the attribute representation of the identifier for a given entity mapping.
   *
   * @param mappedEntity The mapping definition of the entity.
   * @param generator The identifier value generator to use for this identifier.
   * @return The appropriate IdentifierProperty definition.
   */
  public static IdentifierProperty buildIdentifierAttribute(
      PersistentClass mappedEntity, IdentifierGenerator generator) {
    String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
    Type type = mappedEntity.getIdentifier().getType();
    Property property = mappedEntity.getIdentifierProperty();

    IdentifierValue unsavedValue =
        UnsavedValueFactory.getUnsavedIdentifierValue(
            mappedUnsavedValue, getGetter(property), type, getConstructor(mappedEntity));

    if (property == null) {
      // this is a virtual id property...
      return new IdentifierProperty(
          type,
          mappedEntity.hasEmbeddedIdentifier(),
          mappedEntity.hasIdentifierMapper(),
          unsavedValue,
          generator);
    } else {
      return new IdentifierProperty(
          property.getName(),
          property.getNodeName(),
          type,
          mappedEntity.hasEmbeddedIdentifier(),
          unsavedValue,
          generator);
    }
  }