/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
((ObjectLevelReadQuery)query).setReferenceClass(getDescriptor().getJavaClass()); } catch (ConversionException exception) {
/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
((ObjectLevelReadQuery)query).setReferenceClass(getDescriptor().getJavaClass()); } catch (ConversionException exception) {
/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
/** * INTERNAL * Adjust the reference class of the passed query if necessary * * Need to test this for Employee, employee.getAddress(), report query */ public void adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext) { Class referenceClass = getReferenceClass(theQuery, generationContext); if ((referenceClass != null) && (referenceClass != theQuery.getReferenceClass())) { if (theQuery.isObjectLevelReadQuery()) { // The referenceClass needs to be changed. // This should only happen in an ejbSelect... ((ObjectLevelReadQuery)theQuery).setReferenceClass(referenceClass); generationContext.setBaseQueryClass(referenceClass); ((ObjectLevelReadQuery)theQuery).changeDescriptor(generationContext.getSession()); } else if (theQuery.isUpdateAllQuery()) { ((UpdateAllQuery)theQuery).setReferenceClass(referenceClass); } else if (theQuery.isDeleteAllQuery()) { ((DeleteAllQuery)theQuery).setReferenceClass(referenceClass); } } }
/** * INTERNAL * Adjust the reference class of the passed query if necessary * * Need to test this for Employee, employee.getAddress(), report query */ public void adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext) { Class referenceClass = getReferenceClass(theQuery, generationContext); if ((referenceClass != null) && (referenceClass != theQuery.getReferenceClass())) { if (theQuery.isObjectLevelReadQuery()) { // The referenceClass needs to be changed. // This should only happen in an ejbSelect... ((ObjectLevelReadQuery)theQuery).setReferenceClass(referenceClass); generationContext.setBaseQueryClass(referenceClass); ((ObjectLevelReadQuery)theQuery).changeDescriptor(generationContext.getSession()); } else if (theQuery.isUpdateAllQuery()) { ((UpdateAllQuery)theQuery).setReferenceClass(referenceClass); } else if (theQuery.isDeleteAllQuery()) { ((DeleteAllQuery)theQuery).setReferenceClass(referenceClass); } } }
/** * INTERNAL * Adjust the reference class of the passed query if necessary * * Need to test this for Employee, employee.getAddress(), report query */ public void adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext) { Class referenceClass = getReferenceClass(theQuery, generationContext); if ((referenceClass != null) && (referenceClass != theQuery.getReferenceClass())) { if (theQuery.isObjectLevelReadQuery()) { // The referenceClass needs to be changed. // This should only happen in an ejbSelect... ((ObjectLevelReadQuery)theQuery).setReferenceClass(referenceClass); generationContext.setBaseQueryClass(referenceClass); ((ObjectLevelReadQuery)theQuery).changeDescriptor(generationContext.getSession()); } else if (theQuery.isUpdateAllQuery()) { ((UpdateAllQuery)theQuery).setReferenceClass(referenceClass); } else if (theQuery.isDeleteAllQuery()) { ((DeleteAllQuery)theQuery).setReferenceClass(referenceClass); } } }
/** * INTERNAL: * Select all rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the rows. * This does not optimize using type select, as the type information is not known. * @return vector containing database rows. * @exception DatabaseException - an error has occurred on the database. */ protected Vector selectAllRowUsingCustomMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException { Vector rows = new Vector(); // 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())) { ObjectLevelReadQuery concreteQuery = (ObjectLevelReadQuery)query.clone(); concreteQuery.setReferenceClass(getDescriptor().getJavaClass()); concreteQuery.setDescriptor(getDescriptor()); Vector concreteRows = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectAllRowsFromConcreteTable(); rows = Helper.concatenateVectors(rows, concreteRows); } // Recursively collect all rows from all concrete children and their children. // If this descriptor did not have a child with its own table, then the concrete select // would have selected them all. if (hasMultipleTableChild() || !shouldReadSubclasses()) { for (ClassDescriptor concreteDescriptor : getChildDescriptors()) { Vector concreteRows = concreteDescriptor.getInheritancePolicy().selectAllRowUsingCustomMultipleTableSubclassRead(query); rows = Helper.concatenateVectors(rows, concreteRows); } } return rows; }
/** * INTERNAL: * Select all rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the rows. * This does not optimize using type select, as the type information is not known. * @return vector containing database rows. * @exception DatabaseException - an error has occurred on the database. */ protected Vector selectAllRowUsingCustomMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException { Vector rows = new Vector(); // 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())) { ObjectLevelReadQuery concreteQuery = (ObjectLevelReadQuery)query.clone(); concreteQuery.setReferenceClass(getDescriptor().getJavaClass()); concreteQuery.setDescriptor(getDescriptor()); Vector concreteRows = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectAllRowsFromConcreteTable(); rows = Helper.concatenateVectors(rows, concreteRows); } // Recursively collect all rows from all concrete children and their children. // If this descriptor did not have a child with its own table, then the concrete select // would have selected them all. if (hasMultipleTableChild() || !shouldReadSubclasses()) { for (ClassDescriptor concreteDescriptor : getChildDescriptors()) { Vector concreteRows = concreteDescriptor.getInheritancePolicy().selectAllRowUsingCustomMultipleTableSubclassRead(query); rows = Helper.concatenateVectors(rows, concreteRows); } } return rows; }
setReferenceClass(newExampleObject.getClass());
setReferenceClass(newExampleObject.getClass());
void visitAbstractFromClause(AbstractFromClause expression) { // Set the ExpressionBuilder Expression baseExpression = queryContext.getBaseExpression(); ExpressionBuilder expressionBuilder = baseExpression.getBuilder(); query.setExpressionBuilder(expressionBuilder); // Set the reference class if it's not set if (query.getReferenceClass() == null) { query.setReferenceClass(expressionBuilder.getQueryClass()); query.changeDescriptor(queryContext.getSession()); } // Add join expressions to the query (but not the join fetch expressions) JoinVisitor visitor = new JoinVisitor(); expression.accept(visitor); // Visit the AS OF clause if (expression.hasAsOfClause()) { expression.getAsOfClause().accept(this); } // Visit the hierarchical clause if (expression.hasHierarchicalQueryClause()) { expression.getHierarchicalQueryClause().accept(this); } }
void visitAbstractFromClause(AbstractFromClause expression) { // Set the ExpressionBuilder Expression baseExpression = queryContext.getBaseExpression(); ExpressionBuilder expressionBuilder = baseExpression.getBuilder(); query.setExpressionBuilder(expressionBuilder); // Set the reference class if it's not set if (query.getReferenceClass() == null) { query.setReferenceClass(expressionBuilder.getQueryClass()); query.changeDescriptor(queryContext.getSession()); } // Add join expressions to the query (but not the join fetch expressions) JoinVisitor visitor = new JoinVisitor(); expression.accept(visitor); // Visit the AS OF clause if (expression.hasAsOfClause()) { expression.getAsOfClause().accept(this); } // Visit the hierarchical clause if (expression.hasHierarchicalQueryClause()) { expression.getHierarchicalQueryClause().accept(this); } }
theQuery.setReferenceClass(baseClass); theQuery.changeDescriptor(generationContext.getSession()); generationContext.setBaseQueryClass(baseClass);
theQuery.setReferenceClass(baseClass); theQuery.changeDescriptor(generationContext.getSession()); generationContext.setBaseQueryClass(baseClass);
theQuery.setReferenceClass(baseClass); theQuery.changeDescriptor(generationContext.getSession()); generationContext.setBaseQueryClass(baseClass);