use of org.hibernate.metamodel.model.domain.MappedSuperclassDomainType in project hibernate-orm by hibernate.
the class MetadataContext method wrapUp.
@SuppressWarnings("unchecked")
public void wrapUp() {
if (LOG.isTraceEnabled()) {
LOG.trace("Wrapping up metadata context...");
}
boolean staticMetamodelScanEnabled = this.jpaStaticMetaModelPopulationSetting != JpaStaticMetaModelPopulationSetting.DISABLED;
// we need to process types from superclasses to subclasses
for (Object mapping : orderedMappings) {
if (PersistentClass.class.isAssignableFrom(mapping.getClass())) {
final PersistentClass safeMapping = (PersistentClass) mapping;
if (LOG.isTraceEnabled()) {
LOG.trace("Starting entity [" + safeMapping.getEntityName() + ']');
}
try {
final EntityDomainType<Object> jpaMapping = (EntityDomainType<Object>) entityTypesByPersistentClass.get(safeMapping);
applyIdMetadata(safeMapping, jpaMapping);
applyVersionAttribute(safeMapping, jpaMapping);
for (Property property : safeMapping.getDeclaredProperties()) {
if (property.getValue() == safeMapping.getIdentifierMapper()) {
// #buildIdClassAttributes
continue;
}
if (safeMapping.isVersioned() && property == safeMapping.getVersion()) {
// skip the version property, it was already handled previously.
continue;
}
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute(jpaMapping, property);
if (attribute != null) {
addAttribute(jpaMapping, attribute);
if (property.isNaturalIdentifier()) {
((AttributeContainer<Object>) jpaMapping).getInFlightAccess().applyNaturalIdAttribute(attribute);
}
}
}
((AttributeContainer<?>) jpaMapping).getInFlightAccess().finishUp();
if (staticMetamodelScanEnabled) {
populateStaticMetamodel(jpaMapping);
}
} finally {
if (LOG.isTraceEnabled()) {
LOG.trace("Completed entity [" + safeMapping.getEntityName() + ']');
}
}
} else if (MappedSuperclass.class.isAssignableFrom(mapping.getClass())) {
final MappedSuperclass safeMapping = (MappedSuperclass) mapping;
if (LOG.isTraceEnabled()) {
LOG.trace("Starting mapped superclass [" + safeMapping.getMappedClass().getName() + ']');
}
try {
final MappedSuperclassDomainType<Object> jpaType = (MappedSuperclassDomainType<Object>) mappedSuperclassByMappedSuperclassMapping.get(safeMapping);
applyIdMetadata(safeMapping, jpaType);
applyVersionAttribute(safeMapping, jpaType);
for (Property property : safeMapping.getDeclaredProperties()) {
if (safeMapping.isVersioned() && property == safeMapping.getVersion()) {
// skip the version property, it was already handled previously.
continue;
}
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute(jpaType, property);
if (attribute != null) {
addAttribute(jpaType, attribute);
if (property.isNaturalIdentifier()) {
((AttributeContainer<Object>) jpaType).getInFlightAccess().applyNaturalIdAttribute(attribute);
}
}
}
((AttributeContainer<?>) jpaType).getInFlightAccess().finishUp();
if (staticMetamodelScanEnabled) {
populateStaticMetamodel(jpaType);
}
} finally {
if (LOG.isTraceEnabled()) {
LOG.trace("Completed mapped superclass [" + safeMapping.getMappedClass().getName() + ']');
}
}
} else {
throw new AssertionFailure("Unexpected mapping type: " + mapping.getClass());
}
}
while (!embeddablesToProcess.isEmpty()) {
final ArrayList<EmbeddableDomainType<?>> processingEmbeddables = new ArrayList<>(embeddablesToProcess.size());
for (List<EmbeddableDomainType<?>> embeddableDomainTypes : embeddablesToProcess.values()) {
processingEmbeddables.addAll(embeddableDomainTypes);
}
embeddablesToProcess.clear();
for (EmbeddableDomainType<?> embeddable : processingEmbeddables) {
final Component component = componentByEmbeddable.get(embeddable);
for (Property property : component.getProperties()) {
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute((ManagedDomainType<Object>) embeddable, property);
if (attribute != null) {
addAttribute(embeddable, attribute);
}
}
((AttributeContainer<?>) embeddable).getInFlightAccess().finishUp();
embeddables.put(embeddable.getJavaType(), embeddable);
if (staticMetamodelScanEnabled) {
populateStaticMetamodel(embeddable);
}
}
}
}
Aggregations