code: private XmlQueryExpression getQuery(Map<String, Collection<AttributeBean>> attributeMap,
                                          XmlQueryContext context,
                                          int r) throws XmlException  {
          // The dimensions for this query.
          StringBuilder sb = new StringBuilder(64 * attributeMap.size());
          for (Collection<AttributeBean> attributeBeans : attributeMap.values()) {
              sb.append(attributeBeans.size() + ":");
              for (AttributeBean bean : attributeBeans) {
                  sb.append(bean.getValues().size() + "-");
              }
          }
  
          // If a query of these dimensions already exists, then just return it.
          String hash = sb.toString() + r;
          XmlQueryExpression result = m_queries.get(hash);
          if (result != null) {
              return result;
          }
  
          // We do not have a query of those dimensions. We must make one.
          String query = createQuery(attributeMap);
  
          if (log.isDebugEnabled()) {
              log.debug("Query [{}]:\n{}", hash, query);
          }
  
          // Once we have created a query, we can parse it and store the
          // execution plan. This is an expensive operation that we do
          // not want to have to do more than once for each dimension
          result = m_dbXmlManager.manager.prepare(query, context);
  
          m_queries.put(hash, result);
  
          return result;
      }
docs: Either returns a query that has previously been generated, or generates a
  new one if it has not.
  
  @param attributeMap
  the Map of attributes, type and values upon which this query is
  based
  @param context
  the context for the query
  @return an XmlQueryExpression that can be executed
  @throws XmlException
  @throws XmlException
  @throws PolicyIndexException