Problem with ReportQuery and Invalid query key

From: isabelle T. (isabelle.thauvin_at_ipsen.com)
Date: 07/16/04


Date: 16 Jul 2004 01:09:04 -0700

I am using Websphere and Toplink.
I have a table TABLE which have 6 columns for primary key K1, K2, K3,
K4, K5 and K6. This table is mapping with an other table TABLE2 with
the columns K1 and K3. This second table is mapping with an third
table TABLE3 with the column K1.
I am trying to have this select :
SELECT K2 FROM TABLE WHERE K1='toto' GROUP BY K2 ORDERING BY K2,
‘toto' is a parameter.
(or why not this other select : SELECT DISTINCT K2 FROM TABLE WHERE
K1='toto' ORDERING BY K2)
I have a Java class with the following code :

public static void registerQueries(Descriptor in_descriptor) {
   ExpressionBuilder lc_expr = new ExpressionBuilder();
   ReportQuery lc_reportQuery2= new ReportQuery();
   lc_reportQuery2.addAttribute("K2");
   lc_reportQuery2.addArgument("K1");
   lc_reportQuery2.setSelectionCriteria(lc_expr.get("K1").equal(lc_expr.getParameter("K1")));
   lc_reportQuery2.addGrouping("K2");
   lc_reportQuery2.addOrdering(lc_expr.get("K2"));
   in_descriptor.getQueryManager().addQuery("findAllK2",
lc_reportQuery2);
}

I have an other Java class with the following code :

public List findAllK2(String in_K1){
   Vector lc_vector = new Vector(1);
   lc_vector.add(in_K1);
   return getMappingService().listFirstRowsReportQuery("findAllK2",
lc_vector);
}

And finally I have a third Java class with the following code :

public List listFirstRowsReportQuery(String in_queryName, Vector
in_params) {
   List lc_list = new ArrayList();
   Vector lc_reports = (Vector)
getSession().executeQuery(in_queryName, mappedClass, in_params);
   Iterator lc_ite = lc_reports.iterator();
   while (lc_ite.hasNext()) {
      ReportQueryResult lc_reportQueryResult = (ReportQueryResult)
lc_ite.next();
      Vector lc_vector = lc_reportQueryResult.getResults();
      if (lc_vector!=null && lc_vector.get(0)!=null)
lc_list.add(lc_vector.get(0));
   }
   return lc_list;
}

When I try to use all of this coding in an other Java class with the
following code
List lc_listeK2 = (List)
XApplicationFacade.getInstance().getTableService().findAllK2(lc_K1);
I have an error :
EXCEPTION [TOPLINK-6015] (TopLink - 9.0.3.5 (Build 436)):
oracle.toplink.exceptions.QueryException
EXCEPTION DESCRIPTION: Invalid query key [
Query Key site

Can someone help me please ?