/** * 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()); } }
/** * 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()); } }
/** * 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: * 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); }
/** * 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); }
/** * 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); }
/** * <p>INTERNAL: * * Legacy projects have 'findAll' and 'findByPrimaryKey' queries, whereas we now * expect these to have the descriptor alias appended (preceded with underscore), * + 'Type'. For example, if we have an Employee descriptor, the find queries * would be: 'findAll_employeeType' and 'findByPrimaryKey_employeeType'. * */ @SuppressWarnings("rawtypes") protected static void updateFindQueryNames(Project orProject) { for (ClassDescriptor orDesc : orProject.getDescriptors().values()) { Vector queries = orDesc.getQueryManager().getAllQueries(); for (int i=0; i<queries.size(); i++) { DatabaseQuery query = (DatabaseQuery) queries.get(i); String qName = query.getName(); String END_PART = UNDERSCORE_STR + query.getDescriptor().getAlias() + TYPE_STR; if ((PK_QUERYNAME.equals(qName) || ALL_QUERYNAME.equals(qName)) && !qName.endsWith(END_PART)) { orDesc.getQueryManager().addQuery(qName + END_PART, query); } } } }
/** * <p>INTERNAL: * * Legacy projects have 'findAll' and 'findByPrimaryKey' queries, whereas we now * expect these to have the descriptor alias appended (preceded with underscore), * + 'Type'. For example, if we have an Employee descriptor, the find queries * would be: 'findAll_employeeType' and 'findByPrimaryKey_employeeType'. * */ @SuppressWarnings("rawtypes") protected static void updateFindQueryNames(Project orProject) { for (ClassDescriptor orDesc : orProject.getDescriptors().values()) { Vector queries = orDesc.getQueryManager().getAllQueries(); for (int i=0; i<queries.size(); i++) { DatabaseQuery query = (DatabaseQuery) queries.get(i); String qName = query.getName(); String END_PART = UNDERSCORE_STR + query.getDescriptor().getAlias() + TYPE_STR; if ((PK_QUERYNAME.equals(qName) || ALL_QUERYNAME.equals(qName)) && !qName.endsWith(END_PART)) { orDesc.getQueryManager().addQuery(qName + END_PART, 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; }
DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
/** * 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; }
DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
if (q.getName().equals(name)) { foundQuery = true; cd.getQueryManager().addQuery(name, q); break;
if (q.getName().equals(name)) { foundQuery = true; cd.getQueryManager().addQuery(name, q); break;