/** * INTERNAL: * This method is called from individual mappings during their * initialization. If the mapping is to a class within a TABLE_PER_CLASS * inheritance hierarchy, what this method will do is prepare a selection * query to execute for every child descriptor in the hierarchy. * * The selection queries are created by cloning the source mapping, * updating the necessary database fields on the mapping and then * initializing the mapping to create the internal selection query. * This query is then cached where needed using the source mapping's * selection query name as the key. * * @see selectAllObjects(ReadAllQuery) * @see selectOneObject(ReadObjectQuery) */ public void prepareChildrenSelectionQuery(DatabaseMapping sourceMapping, AbstractSession session) { // From collection mappings we must execute a query on every // subclass table to build our results. Tell all children // descriptors to prepare their selection queries. for (ClassDescriptor childDescriptor : (Vector<ClassDescriptor>) getChildDescriptors()) { childDescriptor.getTablePerClassPolicy().prepareSelectionQuery(sourceMapping, session); } }
/** * INTERNAL: * The selection queries are created by cloning the source mapping, * updating the necessary database fields on the mapping and then * initializing the mapping to create the internal selection query. * This query is then cached where needed using the source mapping * as the key. A prepare is performed for each child of the hierarchy. */ protected void prepareSelectionQuery(DatabaseMapping sourceMapping, AbstractSession session) { // Recurse through our child descriptors to set up the selection query // before execution. for (ClassDescriptor childDescriptor : (Vector<ClassDescriptor>) getChildDescriptors()) { childDescriptor.getTablePerClassPolicy().prepareSelectionQuery(sourceMapping, session); } if (sourceMapping.isOneToManyMapping()) { prepareOneToManySelectionQuery((OneToManyMapping) sourceMapping, session); } else if (sourceMapping.isManyToManyMapping()) { prepareManyToManySelectionQuery((ManyToManyMapping) sourceMapping, session); } else if (sourceMapping.isOneToOneMapping()) { prepareOneToOneSelectionQuery((OneToOneMapping) sourceMapping, session); } // No support for other mappings at this point. }