On Wed, Aug 20, 2008 at 2:22 PM, Eric Polino <[EMAIL PROTECTED]> wrote: > Alright sweet! That was it! Thanks. > > Now, QueryChain always returns DataRows because it can't know how to > marshal objects. Clearly the results from the three queries being run > in the following code could be marshaled into List<Student> objects. > Is there a way I can do that? > > SQLTemplate tmpl = new SQLTemplate(TypeFoo.class, "select
Typo, that should be Student.class, and not TypeFoo.class > #result('field1' 'int' 'age'), #result('field2' 'String' 'name') from > Students where age < $bar"); > QueryChain query = new QueryChain(); > > Map<String, String> param = new HashMap<String, String>(); > > param.put("bar", "4"); > query.add(tmpl.queryWithParameters(param)); > > param.put("bar", "7"); > query.add(tmpl.queryWithParameters(param)); > > param.put("bar", "14"); > query.add(tmpl.queryWithParameters(param)); > > QueryResponse response = context.performGenericQuery(query); > > Here's how I'm getting my List<List<DataRow>> object from > performGenericQuery(). It's a little dirty, but it seems to work for > me. Is this any useful to the marshaling I'm talking about above? > > QueryResponse ret = getDataContext().performGenericQuery(query); > List<List<DataRow>> val = new ArrayList<List<DataRow>>(); > ret.reset(); > while(ret.next()){ > if(ret.isList()){ > val.add(ret.currentList()); > } > } > > Once again, TIA, > Eric > > > On Wed, Aug 20, 2008 at 4:09 AM, Andrus Adamchik <[EMAIL PROTECTED]> wrote: >> Hi Eric, >> >> 'performQuery' method will only return the first result set, no matter how >> many results you have in the query. To get all results, you will need to use >> a different method for select: >> >> QueryResponse result = context.performGenericQuery(query); >> >> Then you can scan vis the QueryResponse object and access individual result >> lists: >> >> http://cayenne.apache.org/doc/api/org/apache/cayenne/QueryResponse.html >> >> HTH >> Andrus >> >> >> On Aug 19, 2008, at 5:21 PM, Eric Polino wrote: >> >>> I need to run a group of select queries all at once and would like to >>> parallelize it. I'm attempting to do it with QueryChain but I'm >>> having issues getting the data I'm querying. I know that QueryChain >>> will always return DataRows, but it seems as though I only get the >>> first query's result back and not all of them. I'm using this page >>> from the guide as my starting point. >>> http://cayenne.apache.org/doc/querychain.html >>> >>> QueryChain query = new QueryChain(); >>> >>> query.addQuery(new SQLTemplate(TypeFoo.class, "select count(*) as foo1 >>> from TypeFoo")); >>> query.addQuery(new SQLTemplate(TypeBar.class, "select count(*) as foo2 >>> from TypeBar")); >>> query.addQuery(new SQLTemplate(Type.class, "select count(*) as foo3 >>> from Type")); >>> >>> List<DataRow> ret = getDataContext().performQuery(query); >>> DataRow dr = ret.get(0); >>> >>> System.out.println(ret.size()); // "1" >>> System.out.println(dr.keySet().size()); // "1" >>> System.out.println("FOO1 " + dr.get("FOO1")); // "FOO1 123" >>> System.out.println("FOO2 " + dr.get("FOO2")); // "FOO2 null" >>> System.out.println("FOO3 " + dr.get("FOO3")); // "FOO3 null" >>> >>> TIA, >>> Eric >>> >>> >>> -- >>> Eric Polino >>> Campground Automated Systems >>> >> >> > > > > -- > Eric Polino > Campground Automated Systems > -- Eric Polino Campground Automated Systems