Search in sources :

Example 1 with DynamicModelJavaType

use of org.hibernate.type.descriptor.java.spi.DynamicModelJavaType in project hibernate-orm by hibernate.

the class JpaMetamodelImpl method buildEntityType.

@SuppressWarnings("unchecked")
private EntityTypeImpl<?> buildEntityType(PersistentClass persistentClass, MetadataContext context, TypeConfiguration typeConfiguration) {
    context.pushEntityWorkedOn(persistentClass);
    final MappedSuperclass superMappedSuperclass = persistentClass.getSuperMappedSuperclass();
    IdentifiableDomainType<?> superType = superMappedSuperclass == null ? null : locateOrBuildMappedSuperclassType(superMappedSuperclass, context, typeConfiguration);
    // no mappedSuperclass, check for a super entity
    if (superType == null) {
        final PersistentClass superPersistentClass = persistentClass.getSuperclass();
        superType = superPersistentClass == null ? null : locateOrBuildEntityType(superPersistentClass, context, typeConfiguration);
    }
    final Class<?> javaTypeClass = persistentClass.getMappedClass();
    final JavaType<?> javaType;
    if (javaTypeClass == null || Map.class.isAssignableFrom(javaTypeClass)) {
        // dynamic map
        javaType = new DynamicModelJavaType();
    } else {
        javaType = context.getTypeConfiguration().getJavaTypeRegistry().resolveEntityTypeDescriptor(javaTypeClass);
    }
    final EntityTypeImpl<?> entityType = new EntityTypeImpl(javaType, superType, persistentClass, this);
    context.registerEntityType(persistentClass, entityType);
    context.popEntityWorkedOn(persistentClass);
    return entityType;
}
Also used : MappedSuperclass(org.hibernate.mapping.MappedSuperclass) DynamicModelJavaType(org.hibernate.type.descriptor.java.spi.DynamicModelJavaType) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) PersistentClass(org.hibernate.mapping.PersistentClass)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MappedSuperclass (org.hibernate.mapping.MappedSuperclass)1 PersistentClass (org.hibernate.mapping.PersistentClass)1 DynamicModelJavaType (org.hibernate.type.descriptor.java.spi.DynamicModelJavaType)1