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()));
       }
     }
   }
 }
  private void collectTypes()
      throws IOException, XMLStreamException, ClassNotFoundException, SecurityException,
          NoSuchMethodException {
    // super classes
    Iterator<?> superClassMappings = configuration.getMappedSuperclassMappings();
    while (superClassMappings.hasNext()) {
      MappedSuperclass msc = (MappedSuperclass) superClassMappings.next();
      EntityType entityType = createSuperType(msc.getMappedClass());
      if (msc.getDeclaredIdentifierProperty() != null) {
        handleProperty(entityType, msc.getMappedClass(), msc.getDeclaredIdentifierProperty());
      }
      Iterator<?> properties = msc.getDeclaredPropertyIterator();
      while (properties.hasNext()) {
        handleProperty(
            entityType, msc.getMappedClass(), (org.hibernate.mapping.Property) properties.next());
      }
    }

    // entity classes
    Iterator<?> classMappings = configuration.getClassMappings();
    while (classMappings.hasNext()) {
      PersistentClass pc = (PersistentClass) classMappings.next();
      EntityType entityType = createEntityType(pc.getMappedClass());
      if (pc.getDeclaredIdentifierProperty() != null) {
        handleProperty(entityType, pc.getMappedClass(), pc.getDeclaredIdentifierProperty());
      } else if (!pc.isInherited() && pc.hasIdentifierProperty()) {
        logger.info(entityType.toString() + pc.getIdentifierProperty());
        handleProperty(entityType, pc.getMappedClass(), pc.getIdentifierProperty());
      }
      Iterator<?> properties = pc.getDeclaredPropertyIterator();
      while (properties.hasNext()) {
        handleProperty(
            entityType, pc.getMappedClass(), (org.hibernate.mapping.Property) properties.next());
      }
    }
  }