* INTERNAL:
* The process method method will be called with the descriptor from
* every entity in the hierarchy.
*/
public void process(MetadataDescriptor descriptor) {
EntityAccessor accessor = (EntityAccessor) descriptor.getClassAccessor();
// Set the correct inheritance policy.
if (m_strategy != null && m_strategy.name().equals(InheritanceType.TABLE_PER_CLASS.name())) {
setTablePerClassInheritancePolicy(descriptor);
} else {
setInheritancePolicy(descriptor);
}
// Process an inheritance subclass.
if (descriptor.isInheritanceSubclass()) {
MetadataDescriptor rootDescriptor = descriptor.getInheritanceRootDescriptor();
EntityAccessor rootAccessor = (EntityAccessor) rootDescriptor.getClassAccessor();
if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
MetadataDescriptor parentDescriptor = descriptor.getInheritanceParentDescriptor();
descriptor.getClassDescriptor().getTablePerClassPolicy().addParentDescriptor(parentDescriptor.getClassDescriptor());
parentDescriptor.getClassDescriptor().getTablePerClassPolicy().addChildDescriptor(descriptor.getClassDescriptor());
} else {
// Set the parent class on the inheritance policy.
descriptor.getClassDescriptor().getInheritancePolicy().setParentClassName(descriptor.getInheritanceParentDescriptor().getJavaClassName());
}
// If we have inheritance defined then we are a root parent and the
// strategy should be changing meaning we have double the work to do.
// Note: if the strategy does not change, then we ignore the inheritance
// hierarchy and continue as if we were a simple inheritance subclass.
if (accessor.hasInheritance() && ! equals(rootAccessor.getInheritance())) {
// If our parent was a table per class strategy then we need
// to add the table per class mappings.
if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
// Go through our parents (including their mapped superclasses
// and add their accessors to our list of accessors.
addTablePerClassParentMappings(descriptor, descriptor);
} else {
if (! usesTablePerClassStrategy()) {
// We are either a JOINED or SINGLE_TABLE strategy and we
// need to process our specific inheritance metadata.
addClassIndicatorField(descriptor, accessor);
addClassIndicator(rootDescriptor, accessor);
}
// The strategies are changing so must process some
// join columns to link up the classes.
accessor.processInheritancePrimaryKeyJoinColumns();
}
} else {
// We are a simple inheritance subclass.
if (usesTablePerClassStrategy()) {
// Go through our parents (including their mapped superclasses
// and add their accessors to our list of accessors.
addTablePerClassParentMappings(descriptor, descriptor);
} else {
// We have metadata we need to set on our root parent.
addClassIndicator(rootDescriptor, accessor);
// Process join columns if necessary.
if (rootAccessor.getInheritance().usesJoinedStrategy()) {
accessor.processInheritancePrimaryKeyJoinColumns();
}
}
}