manager.setQueries(new Hashtable(getQueries().size())); Iterator iterator = queries.values().iterator(); while (iterator.hasNext()) { DatabaseQuery initialQuery = (DatabaseQuery)queriesForKey.next(); DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery); manager.setDoesExistQuery((DoesExistQuery)getDoesExistQuery().clone()); if (getReadAllQuery() != null) { manager.setReadAllQuery((ReadAllQuery)getReadAllQuery().clone()); if (getReadObjectQuery() != null) { manager.setReadObjectQuery((ReadObjectQuery)getReadObjectQuery().clone()); if (getUpdateQuery() != null) { manager.setUpdateQuery((UpdateObjectQuery)getUpdateQuery().clone()); if (getInsertQuery() != null) { manager.setInsertQuery((InsertObjectQuery)getInsertQuery().clone()); if (getDeleteQuery() != null) { manager.setDeleteQuery((DeleteObjectQuery)getDeleteQuery().clone());
/** * INTERNAL: * This method is explicitly used by the Builder only. */ public void setExistenceCheck(String token) throws DescriptorException { if (token.equals("Check cache")) { checkCacheForDoesExist(); } else if (token.equals("Check database")) { checkDatabaseForDoesExist(); } else if (token.equals("Assume existence")) { assumeExistenceForDoesExist(); } else if (token.equals("Assume non-existence")) { assumeNonExistenceForDoesExist(); } else { throw DescriptorException.setExistenceCheckingNotUnderstood(token, getDescriptor()); } }
if (getDescriptor().isAggregateDescriptor()) { return; if (getMultipleTableJoinExpression() != null) { setAdditionalJoinExpression(getMultipleTableJoinExpression().and(getAdditionalJoinExpression())); if (getDescriptor().isAggregateCollectionDescriptor()) { return; if (!hasReadObjectQuery()) { readObjectQuery.setSelectionCriteria(getDescriptor().getObjectBuilder().getPrimaryKeyExpression()); setReadObjectQuery(readObjectQuery); if (!hasInsertQuery()) { setInsertQuery(new InsertObjectQuery()); getInsertQuery().setModifyRow(getDescriptor().getObjectBuilder().buildTemplateInsertRow(session)); if (!hasDeleteQuery()) { setDeleteQuery(new DeleteObjectQuery()); getDeleteQuery().setModifyRow(new DatabaseRecord()); if (hasUpdateQuery()) {
if (getInsertQuery() != null) { getInsertQuery().setDescriptor(descriptor); if (getUpdateQuery() != null) { getUpdateQuery().setDescriptor(descriptor); if (getReadObjectQuery() != null) { getReadObjectQuery().setReferenceClass(getDescriptor().getJavaClass()); getReadObjectQuery().setDescriptor(descriptor); if (getDeleteQuery() != null) { getDeleteQuery().setDescriptor(descriptor); if (getReadAllQuery() != null) { getReadAllQuery().setReferenceClass(getDescriptor().getJavaClass()); getReadAllQuery().setDescriptor(descriptor); for (Iterator it = getAllQueries().iterator(); it.hasNext();) { ((DatabaseQuery)it.next()).setDescriptor(descriptor);
/** * 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(getDescriptor().getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
getDescriptor().setAdditionalTablePrimaryKeyFields(Helper.concatenateMaps(getParentDescriptor().getAdditionalTablePrimaryKeyFields(), getDescriptor().getAdditionalTablePrimaryKeyFields())); Expression localExpression = getDescriptor().getQueryManager().getMultipleTableJoinExpression(); Expression parentExpression = getParentDescriptor().getQueryManager().getMultipleTableJoinExpression(); getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(localExpression.and(parentExpression)); } else if (parentExpression != null) { getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(parentExpression); Expression localAdditionalExpression = getDescriptor().getQueryManager().getAdditionalJoinExpression(); Expression parentAdditionalExpression = getParentDescriptor().getQueryManager().getAdditionalJoinExpression(); getDescriptor().getQueryManager().setAdditionalJoinExpression(localAdditionalExpression.and(parentAdditionalExpression)); } else if (parentAdditionalExpression != null) { getDescriptor().getQueryManager().setAdditionalJoinExpression(parentAdditionalExpression);
&& item.getDescriptor().getQueryManager().getAdditionalJoinExpression() != null && !(((ExpressionBuilder)clonedBuilder).wasAdditionJoinCriteriaUsed()) ){ if (selectStatement.getWhereClause() == null ) { selectStatement.setWhereClause(item.getDescriptor().getQueryManager().getAdditionalJoinExpression().rebuildOn(clonedBuilder)); } else { selectStatement.setWhereClause(selectStatement.getWhereClause().and(item.getDescriptor().getQueryManager().getAdditionalJoinExpression().rebuildOn(clonedBuilder)));
clonedDescriptor.setQueryManager((DescriptorQueryManager)getQueryManager().clone()); clonedDescriptor.getQueryManager().setDescriptor(clonedDescriptor);
getDescriptor().getQueryManager().setAdditionalJoinExpression(getOnlyInstancesExpression().and(getDescriptor().getQueryManager().getAdditionalJoinExpression()));
/** * INTERNAL: * Set pre-defined queries for the descriptor. Converts the Vector to a hashtable */ public void setAllQueries(Vector vector) { for (Enumeration enumtr = vector.elements(); enumtr.hasMoreElements();) { addQuery((DatabaseQuery)enumtr.nextElement()); } }
/** * PUBLIC: * Switch all descriptors to check the cache for existence. */ public void checkCacheForDoesExist() { Iterator descriptors = getDescriptors().values().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); descriptor.getQueryManager().checkCacheForDoesExist(); } }
/** * PUBLIC: * Switch all descriptors to assume existence for non-null primary keys. */ public void assumeExistenceForDoesExist() { Iterator descriptors = getDescriptors().values().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); descriptor.getQueryManager().assumeExistenceForDoesExist(); } }
/** * PUBLIC: * Switch all descriptors to check the database for existence. */ public void checkDatabaseForDoesExist() { Iterator descriptors = getDescriptors().values().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); descriptor.getQueryManager().checkDatabaseForDoesExist(); } }
setInstantiationPolicy(new InstantiationPolicy()); setEventManager(new oracle.toplink.essentials.descriptors.DescriptorEventManager()); setQueryManager(new oracle.toplink.essentials.descriptors.DescriptorQueryManager());
getCMPPolicy().convertClassNamesToClasses(classLoader); queryManager.convertClassNamesToClasses(classLoader);
/** * INTERNAL: * Selection criteria is created with source foreign keys and target keys. */ protected void initializePrivateOwnedCriteria() { if (!isForeignKeyRelationship()) { setPrivateOwnedCriteria(getSelectionCriteria()); } else { Expression pkCriteria = getDescriptor().getObjectBuilder().getPrimaryKeyExpression(); ExpressionBuilder builder = new ExpressionBuilder(); Expression backRef = builder.getManualQueryKey(getAttributeName() + "-back-ref", getDescriptor()); Expression newPKCriteria = pkCriteria.rebuildOn(backRef); Expression twistedSelection = backRef.twist(getSelectionCriteria(), builder); if (getDescriptor().getQueryManager().getAdditionalJoinExpression() != null) { // We don't have to twist the additional join because it's all against the same node, which is our base // but we do have to rebuild it onto the manual query key Expression rebuiltAdditional = getDescriptor().getQueryManager().getAdditionalJoinExpression().rebuildOn(backRef); if (twistedSelection == null) { twistedSelection = rebuiltAdditional; } else { twistedSelection = twistedSelection.and(rebuiltAdditional); } } setPrivateOwnedCriteria(newPKCriteria.and(twistedSelection)); } }
/** * PUBLIC: * Add the query to the descriptor queries with the given name * @param name This is the name of the query. It will be set on the query and used to look it up. * @param query This is the query that will be added. If the query being added has parameters, the * existing list of queries will be checked for matching queries. If a matching query exists, * it will be replaced. */ public void addQuery(String name, DatabaseQuery query) { query.setName(name); addQuery(query); }
/** * Return the appropriate select statement to perform a does exist check * @param fields - fields for does exist check. */ protected SQLSelectStatement buildSelectStatementForDoesExist(DatabaseField field) { // Build appropriate select statement SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.addField(field); selectStatement.setWhereClause(((Expression)getDescriptor().getObjectBuilder().getPrimaryKeyExpression().clone()).and(getDescriptor().getQueryManager().getAdditionalJoinExpression())); selectStatement.setTranslationRow(getTranslationRow()); selectStatement.normalize(getSession(), getQuery().getDescriptor()); return selectStatement; }
/** * INTERNAL: * Return the expression to join the main table of this node to any auxiliary tables. */ public Expression additionalExpressionCriteria() { if (getDescriptor() == null) { return null; } Expression criteria = getDescriptor().getQueryManager().getAdditionalJoinExpression(); if(getSession().getPlatform().shouldPrintOuterJoinInWhereClause()) { if(isUsingOuterJoinForMultitableInheritance()) { Expression childrenCriteria = getDescriptor().getInheritancePolicy().getChildrenJoinExpression(); childrenCriteria = getBaseExpression().twist(childrenCriteria, this); childrenCriteria.convertToUseOuterJoin(); if(criteria == null) { criteria = childrenCriteria; } else { criteria = criteria.and(childrenCriteria); } } } return criteria; }
if (queryManager.getAdditionalJoinExpression() != null) { Expression additionalJoin = (Expression)queryManager.getAdditionalJoinExpression();