/** * PUBLIC: * Return if the descriptor defines inheritence and is a child. */ public boolean isChildDescriptor() { return hasInheritance() && getInheritancePolicy().isChildDescriptor(); }
/** * INTERNAL: * Post initialize the child descriptors */ protected void addClassIndicatorTypeToParent(Object indicator) { ClassDescriptor parentDescriptor = getDescriptor().getInheritancePolicy().getParentDescriptor(); if (parentDescriptor.getInheritancePolicy().isChildDescriptor()) { if (parentDescriptor.getInheritancePolicy().shouldReadSubclasses()) { parentDescriptor.getInheritancePolicy().getAllChildClassIndicators().addElement(indicator); } parentDescriptor.getInheritancePolicy().addClassIndicatorTypeToParent(indicator); } }
/** * INTERNAL: * Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid. */ protected void initializeClassExtractor(AbstractSession session) throws DescriptorException { if (getClassExtractor() == null) { if (isChildDescriptor()) { setClassExtractor(getParentDescriptor().getInheritancePolicy().getClassExtractor()); } } else { getClassExtractor().initialize(getDescriptor(), session); } }
boolean isChild = hasInheritance() && getInheritancePolicy().isChildDescriptor(); if (isChild) { additionalTablesSize = getTables().size() - getInheritancePolicy().getParentDescriptor().getTables().size();
/** * INTERNAL: * Recursively adds fields to all the parents */ protected void addFieldsToParent(Vector fields) { if (isChildDescriptor()) { if (getParentDescriptor().isInvalid()) { return; } ClassDescriptor parentDescriptor = getParentDescriptor(); if (parentDescriptor.getInheritancePolicy().shouldReadSubclasses()) { Helper.addAllUniqueToVector(parentDescriptor.getAllFields(), fields); } parentDescriptor.getInheritancePolicy().addFieldsToParent(fields); } }
/** * INTERNAL: * Initialize the expression to use for queries to the class and its subclasses. */ protected void initializeWithAllSubclassesExpression() throws DescriptorException { if (getWithAllSubclassesExpression() == null) { if (hasClassExtractor()) { return; } if (isChildDescriptor() && shouldReadSubclasses()) { setWithAllSubclassesExpression(new ExpressionBuilder().getField(getClassIndicatorField()).in(getAllChildClassIndicators())); } } }
/** * INTERNAL: * For aggregate mapping the reference descriptor is cloned. Also the involved inheritanced descriptor, its childern * and parents all need to be cloned. The cloned descriptors are then assigned primary keys and table names before * initialize. Once cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. * This is a very specifiec behaviour for aggregate mappings. The original descriptor is used only for creating clones * and after that mapping never uses it. * Some initialization is done in postInitialize to ensure the target descriptor's references are initialized. */ public void initializeParentInheritance(ClassDescriptor parentDescriptor, ClassDescriptor childDescriptor, AbstractSession session) throws DescriptorException { if (!parentDescriptor.isAggregateCollectionDescriptor()) { session.getIntegrityChecker().handleError(DescriptorException.referenceDescriptorIsNotAggregateCollection(parentDescriptor.getJavaClass().getName(), this)); } ClassDescriptor clonedParentDescriptor = (ClassDescriptor)parentDescriptor.clone(); //recursive call to the further parent descriptors if (clonedParentDescriptor.getInheritancePolicy().isChildDescriptor()) { ClassDescriptor parentToParentDescriptor = session.getDescriptor(clonedParentDescriptor.getJavaClass()); initializeParentInheritance(parentToParentDescriptor, parentDescriptor, session); } Vector childern = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1); childern.addElement(childDescriptor); clonedParentDescriptor.getInheritancePolicy().setChildDescriptors(childern); clonedParentDescriptor.preInitialize(session); clonedParentDescriptor.initialize(session); }
/** * INTERNAL: * For an aggregate mapping the reference descriptor is cloned. * If the reference descriptor is involved in an inheritance tree, * all the parent and child descriptors are cloned also. * The cloned descriptors are then assigned primary keys and * table names before initialize. * This is a very specific behaviour for aggregate mappings. */ public void initializeParentInheritance(ClassDescriptor parentDescriptor, ClassDescriptor childDescriptor, AbstractSession session) throws DescriptorException { ClassDescriptor clonedParentDescriptor = (ClassDescriptor)parentDescriptor.clone(); //recursive call to the further parent descriptors if (clonedParentDescriptor.getInheritancePolicy().isChildDescriptor()) { ClassDescriptor parentToParentDescriptor = session.getDescriptor(clonedParentDescriptor.getJavaClass()); initializeParentInheritance(parentToParentDescriptor, parentDescriptor, session); } initializeReferenceDescriptor(clonedParentDescriptor); Vector children = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1); children.addElement(childDescriptor); clonedParentDescriptor.getInheritancePolicy().setChildDescriptors(children); clonedParentDescriptor.preInitialize(session); clonedParentDescriptor.initialize(session); translateFields(clonedParentDescriptor, session); }
if (getInheritancePolicy().isChildDescriptor()) { for (Iterator iterator = getInheritancePolicy().getParentDescriptor().getMappings().iterator(); iterator.hasNext();) {
if (isChildDescriptor()) { if (!isChildDescriptor()) {
if (isChildDescriptor()) { getDescriptor().setMappings(Helper.concatenateVectors(getParentDescriptor().getMappings(), getDescriptor().getMappings())); getDescriptor().setQueryKeys(Helper.concatenateMaps(getParentDescriptor().getQueryKeys(), getDescriptor().getQueryKeys()));