// Clear out any previous mapped superclasses and inheritance parents
// that were discovered.
clearMappedSuperclassesAndInheritanceParents();
EntityAccessor currentAccessor = this;
MetadataClass parent = getJavaClass().getSuperclass();
List<String> genericTypes = getJavaClass().getGenericType();
// We keep a list of potential subclass accessors to ensure they
// have their root parent descriptor set correctly.
List<EntityAccessor> subclassAccessors = new ArrayList<EntityAccessor>();
subclassAccessors.add(currentAccessor);
if ((parent != null) && !parent.isObject()) {
while ((parent != null) && !parent.isObject()) {
EntityAccessor parentAccessor = getProject().getEntityAccessor(parent.getName());
// We found a parent entity.
if (parentAccessor != null) {
// Set the immediate parent's descriptor to the current descriptor.
currentAccessor.getDescriptor().setInheritanceParentDescriptor(parentAccessor.getDescriptor());
// Update the current accessor.
currentAccessor = parentAccessor;
// Clear out any previous mapped superclasses and inheritance
// parents that were discovered. We're going to re-discover
// them now.
currentAccessor.clearMappedSuperclassesAndInheritanceParents();
// If we found an entity with inheritance metadata, set the
// root descriptor on its subclasses.
if (currentAccessor.hasInheritance()) {
for (EntityAccessor subclassAccessor : subclassAccessors) {
subclassAccessor.getDescriptor().setInheritanceRootDescriptor(currentAccessor.getDescriptor());
}
// Clear the subclass list, we'll keep looking but the
// inheritance strategy may have changed so we need to
// build a new list of subclasses.
subclassAccessors.clear();
}
// Add the descriptor to the subclass list
subclassAccessors.add(currentAccessor);
// Resolve any generic types from the generic parent onto the
// current descriptor.
currentAccessor.resolveGenericTypes(genericTypes, parent);
} else {
// Might be a mapped superclass, check and add as needed.
currentAccessor.addPotentialMappedSuperclass(parent, addMappedSuperclassAccessors);
// Resolve any generic types from the generic parent onto the
// current descriptor.
currentAccessor.resolveGenericTypes(genericTypes, parent);
}
// Get the next parent and keep processing ...
genericTypes = parent.getGenericType();
parent = parent.getSuperclass();
}
} else {
// Resolve any generic types we have (we may be an inheritance root).
currentAccessor.resolveGenericTypes(genericTypes, parent);
}