@Override
  public void bindMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
    AnnotationBindingContext context =
        new AnnotationBindingContext(index, metadata.getServiceRegistry());
    // need to order our annotated entities into an order we can process
    Set<ConfiguredClassHierarchy<EntityClass>> hierarchies =
        ConfiguredClassHierarchyBuilder.createEntityHierarchies(context);

    // now we process each hierarchy one at the time
    Hierarchical parent = null;
    for (ConfiguredClassHierarchy<EntityClass> hierarchy : hierarchies) {
      for (EntityClass entityClass : hierarchy) {
        // for classes annotated w/ @Entity we create a EntityBinding
        if (ConfiguredClassType.ENTITY.equals(entityClass.getConfiguredClassType())) {
          LOG.bindingEntityFromAnnotatedClass(entityClass.getName());
          EntityBinder entityBinder = new EntityBinder(metadata, entityClass, parent);
          EntityBinding binding = entityBinder.bind();
          parent = binding.getEntity();
        }
        // for classes annotated w/ @MappedSuperclass we just create the domain instance
        // the attribute bindings will be part of the first entity subclass
        else if (ConfiguredClassType.MAPPED_SUPERCLASS.equals(
            entityClass.getConfiguredClassType())) {
          parent = new Superclass(entityClass.getName(), parent);
        }
        // for classes which are not annotated at all we create the NonEntity domain class
        // todo - not sure whether this is needed. It might be that we don't need this information
        // (HF)
        else {
          parent = new NonEntity(entityClass.getName(), parent);
        }
      }
    }
  }
  @Test
  public void testTablePerClassDefaultTableName() {
    @Entity
    @Inheritance(strategy = javax.persistence.InheritanceType.TABLE_PER_CLASS)
    class A {
      @Id @GeneratedValue private int id;
    }

    @Entity
    class B extends A {}

    Index index = JandexHelper.indexForClass(service, A.class, B.class);
    AnnotationBindingContext context = new AnnotationBindingContext(index, serviceRegistry);
    Set<ConfiguredClassHierarchy<EntityClass>> hierarchies =
        ConfiguredClassHierarchyBuilder.createEntityHierarchies(context);
    assertEquals("There should be only one hierarchy", 1, hierarchies.size());

    Iterator<EntityClass> iter = hierarchies.iterator().next().iterator();
    EntityClass entityClass = iter.next();
    ClassInfo info = entityClass.getClassInfo();
    assertEquals("wrong class", DotName.createSimple(A.class.getName()), info.name());
    assertTrue(entityClass.hasOwnTable());
    Assert.assertEquals(
        "wrong inheritance type",
        InheritanceType.TABLE_PER_CLASS,
        entityClass.getInheritanceType());
    Assert.assertEquals("wrong table name", "A", entityClass.getPrimaryTableName());

    assertTrue(iter.hasNext());
    entityClass = iter.next();
    info = entityClass.getClassInfo();
    assertEquals("wrong class", DotName.createSimple(B.class.getName()), info.name());
    assertTrue(entityClass.hasOwnTable());
    Assert.assertEquals(
        "wrong inheritance type",
        InheritanceType.TABLE_PER_CLASS,
        entityClass.getInheritanceType());
    Assert.assertEquals("wrong table name", "B", entityClass.getPrimaryTableName());

    assertFalse(iter.hasNext());
  }