/** * INTERNAL: * Select one object of any concrete subclass. */ protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { ReadObjectQuery concreteQuery = (ReadObjectQuery) query.clone(); Class javaClass = descriptor.getJavaClass(); concreteQuery.setReferenceClass(javaClass); concreteQuery.setDescriptor(descriptor); return query.getSession().executeQuery(concreteQuery, concreteQuery.getTranslationRow()); }
/** * INTERNAL: * Select one rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes until a row is found. * This does not optimize using type select, as the type information is not known. * @exception DatabaseException - an error has occurred on the database. */ protected AbstractRecord selectOneRowUsingCustomMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException { // CR#3701077, it must either have a filter only instances expression, or not have subclasses. // This method recurses, so even though this is only called when shouldReadSubclasses is true, it may be false for subclasses. if ((getOnlyInstancesExpression() != null) || (! shouldReadSubclasses())) { ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(getDescriptor().getJavaClass()); concreteQuery.setDescriptor(getDescriptor()); AbstractRecord row = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); if (row != null) { return row; } } // Recursively collect all rows from all concrete children and their children. for (Enumeration childrenEnum = getChildDescriptors().elements(); childrenEnum.hasMoreElements();) { ClassDescriptor concreteDescriptor = (ClassDescriptor)childrenEnum.nextElement(); AbstractRecord row = concreteDescriptor.getInheritancePolicy().selectOneRowUsingCustomMultipleTableSubclassRead(query); if (row != null) { return row; } } return null; }
manager.setReadObjectQuery((ReadObjectQuery)getReadObjectQuery().clone());
manager.setReadObjectQuery((ReadObjectQuery)getReadObjectQuery().clone());
manager.setReadObjectQuery((ReadObjectQuery)getReadObjectQuery().clone());
} else { query.checkPrepare(session, null); query = (ReadObjectQuery) query.clone();
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }
/** * INTERNAL: * Select one rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes until a row is found. * This does not optimize using type select, as the type information is not known. * @exception DatabaseException - an error has occurred on the database. */ protected AbstractRecord selectOneRowUsingCustomMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException { // CR#3701077, it must either have a filter only instances expression, or not have subclasses. // This method recurses, so even though this is only called when shouldReadSubclasses is true, it may be false for subclasses. if ((getOnlyInstancesExpression() != null) || (! shouldReadSubclasses())) { ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(getDescriptor().getJavaClass()); concreteQuery.setDescriptor(getDescriptor()); AbstractRecord row = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); if (row != null) { return row; } } // Recursively collect all rows from all concrete children and their children. for (ClassDescriptor concreteDescriptor : getChildDescriptors()) { AbstractRecord row = concreteDescriptor.getInheritancePolicy().selectOneRowUsingCustomMultipleTableSubclassRead(query); if (row != null) { return row; } } return null; }
/** * INTERNAL: * Select one rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes until a row is found. * This does not optimize using type select, as the type information is not known. * @exception DatabaseException - an error has occurred on the database. */ protected AbstractRecord selectOneRowUsingCustomMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException { // CR#3701077, it must either have a filter only instances expression, or not have subclasses. // This method recurses, so even though this is only called when shouldReadSubclasses is true, it may be false for subclasses. if ((getOnlyInstancesExpression() != null) || (! shouldReadSubclasses())) { ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(getDescriptor().getJavaClass()); concreteQuery.setDescriptor(getDescriptor()); AbstractRecord row = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); if (row != null) { return row; } } // Recursively collect all rows from all concrete children and their children. for (ClassDescriptor concreteDescriptor : getChildDescriptors()) { AbstractRecord row = concreteDescriptor.getInheritancePolicy().selectOneRowUsingCustomMultipleTableSubclassRead(query); if (row != null) { return row; } } return null; }
ReadObjectQuery customQuery = this.descriptor.getQueryManager().getReadObjectQuery(); if (this.accessors != null) { customQuery = (ReadObjectQuery) customQuery.clone(); customQuery.setIsExecutionClone(true); customQuery.setAccessors(this.accessors);
setReadObjectQuery((ReadObjectQuery)parentQueryManager.getReadObjectQuery().clone());
setReadObjectQuery((ReadObjectQuery)parentQueryManager.getReadObjectQuery().clone());
setReadObjectQuery((ReadObjectQuery)parentQueryManager.getReadObjectQuery().clone());