code: private <X> AbstractManagedType<X> buildManagedType(Class<X> clazz, boolean isIdClass)
      {
          AbstractManagedType<X> managedType = null;
          if (clazz.isAnnotationPresent(Embeddable.class))
          {
  
              validate(clazz, true);
              if (!embeddables.containsKey(clazz))
              {
                  managedType = new DefaultEmbeddableType<X>(clazz, PersistenceType.EMBEDDABLE, getType(
                          clazz.getSuperclass(), isIdClass));
                  onDeclaredFields(clazz, managedType);
                  embeddables.put(clazz, managedType);
              }
              else
              {
                  managedType = (AbstractManagedType<X>) embeddables.get(clazz);
              }
  
          }
          else if (clazz.isAnnotationPresent(MappedSuperclass.class))
          {
  
              validate(clazz, false);
              // if (!mappedSuperClassTypes.containsKey(clazz))
              // {
              managedType = new DefaultMappedSuperClass<X>(clazz, PersistenceType.MAPPED_SUPERCLASS,
                      (AbstractIdentifiableType) getType(clazz.getSuperclass(), isIdClass));
              onDeclaredFields(clazz, managedType);
              mappedSuperClassTypes.put(clazz, (MappedSuperclassType<?>) managedType);
              // }
              // else
              // {
              // managedType = (AbstractManagedType<X>)
              // mappedSuperClassTypes.get(clazz);
              // }
          }
          else if (clazz.isAnnotationPresent(Entity.class) || isIdClass)
          {
              if (!managedTypes.containsKey(clazz))
              {
                  managedType = new DefaultEntityType<X>(clazz, PersistenceType.ENTITY,
                          (AbstractIdentifiableType) getType(clazz.getSuperclass(), isIdClass));
                  // in case of @IdClass, it is a temporary managed type.
                  if (!isIdClass)
                  {
                      managedTypes.put(clazz, (EntityType<?>) managedType);
                  }
              }
              else
              {
                  managedType = (AbstractManagedType<X>) managedTypes.get(clazz);
              }
          }
  
          return managedType;
      }
docs: Builds the managed type.
  
  @param <X>
  the generic type
  @param clazz
  the clazz
  @return the abstract managed type