use of org.hibernate.type.descriptor.java.spi.EntityJavaType in project hibernate-orm by hibernate.
the class JpaMetamodelImpl method processJpa.
public void processJpa(MetadataImplementor bootMetamodel, MappingMetamodel mappingMetamodel, Map<Class<?>, String> entityProxyInterfaceMap, JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting, JpaMetaModelPopulationSetting jpaMetaModelPopulationSetting, Collection<NamedEntityGraphDefinition> namedEntityGraphDefinitions, RuntimeModelCreationContext runtimeModelCreationContext) {
bootMetamodel.getImports().forEach((k, v) -> this.nameToImportMap.put(k, new ImportInfo<>(v, null)));
this.entityProxyInterfaceMap.putAll(entityProxyInterfaceMap);
final MetadataContext context = new MetadataContext(this, mappingMetamodel, bootMetamodel, jpaStaticMetaModelPopulationSetting, jpaMetaModelPopulationSetting, runtimeModelCreationContext);
for (PersistentClass entityBinding : bootMetamodel.getEntityBindings()) {
locateOrBuildEntityType(entityBinding, context, typeConfiguration);
}
handleUnusedMappedSuperclasses(context, typeConfiguration);
context.wrapUp();
for (Map.Entry<String, IdentifiableDomainType<?>> entry : context.getIdentifiableTypesByName().entrySet()) {
if (entry.getValue() instanceof EntityDomainType<?>) {
this.jpaEntityTypeMap.put(entry.getKey(), (EntityDomainType<?>) entry.getValue());
}
}
this.jpaManagedTypeMap.putAll(context.getEntityTypeMap());
this.jpaManagedTypeMap.putAll(context.getMappedSuperclassTypeMap());
switch(jpaMetaModelPopulationSetting) {
case IGNORE_UNSUPPORTED:
this.jpaManagedTypes.addAll(context.getEntityTypeMap().values());
this.jpaManagedTypes.addAll(context.getMappedSuperclassTypeMap().values());
break;
case ENABLED:
this.jpaManagedTypes.addAll(context.getIdentifiableTypesByName().values());
break;
}
for (EmbeddableDomainType<?> embeddable : context.getEmbeddableTypeSet()) {
switch(jpaMetaModelPopulationSetting) {
case IGNORE_UNSUPPORTED:
if (embeddable.getJavaType() != null && embeddable.getJavaType() != Map.class) {
this.jpaEmbeddables.add(embeddable);
this.jpaManagedTypes.add(embeddable);
if (!(embeddable.getExpressibleJavaType() instanceof EntityJavaType<?>)) {
this.jpaManagedTypeMap.put(embeddable.getJavaType(), embeddable);
}
}
break;
case ENABLED:
this.jpaEmbeddables.add(embeddable);
this.jpaManagedTypes.add(embeddable);
if (embeddable.getJavaType() != null && !(embeddable.getExpressibleJavaType() instanceof EntityJavaType<?>)) {
this.jpaManagedTypeMap.put(embeddable.getJavaType(), embeddable);
}
break;
case DISABLED:
if (embeddable.getJavaType() == null) {
throw new UnsupportedOperationException("ANY not supported");
}
if (!(embeddable.getExpressibleJavaType() instanceof EntityJavaType<?>)) {
this.jpaManagedTypeMap.put(embeddable.getJavaType(), embeddable);
}
break;
}
}
final Consumer<PersistentAttribute<?, ?>> attributeConsumer = persistentAttribute -> {
if (persistentAttribute.getJavaType() != null && persistentAttribute.getJavaType().isEnum()) {
@SuppressWarnings("unchecked") final Class<Enum<?>> enumClass = (Class<Enum<?>>) persistentAttribute.getJavaType();
final Enum<?>[] enumConstants = enumClass.getEnumConstants();
for (Enum<?> enumConstant : enumConstants) {
final String qualifiedEnumLiteral = enumConstant.getDeclaringClass().getSimpleName() + "." + enumConstant.name();
this.allowedEnumLiteralTexts.computeIfAbsent(enumConstant.name(), k -> new HashMap<>()).put(enumClass, enumConstant);
this.allowedEnumLiteralTexts.computeIfAbsent(qualifiedEnumLiteral, k -> new HashMap<>()).put(enumClass, enumConstant);
}
}
};
domainTypeStream(context).forEach(managedDomainType -> managedDomainType.visitAttributes(attributeConsumer));
applyNamedEntityGraphs(namedEntityGraphDefinitions);
}
Aggregations