cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylwia Bugla <syl-...@dcc.fc.up.pt>
Subject ClassCastException with SQLResult and SQLTemplate
Date Thu, 01 Sep 2011 05:58:20 GMT
Hello everyone.
I am getting desperate about this issue. I have a simple piece of code
whose purpose is to make some counts in the database. It goes like
this:

String sql = "SELECT a.author_id X, count(*) CNT FROM
`publication_authors` a WHERE a.`cid` != 0 and a.cid = 1234  group by
a.author_id ORDER BY a.`cid` ASC";

            SQLTemplate query = new
SQLTemplate(PublicationAuthors.class, sql);
            query.setFetchingDataRows(true);

            SQLResult resultDescriptor = new SQLResult();
            resultDescriptor.addColumnResult("X");
            resultDescriptor.addColumnResult("CNT");
            query.setResult(resultDescriptor);

            List objects =  context.performQuery(query);

            for(Object o: objects){
                Map dr = (Map) o; //tried with PublicationAuthors,
DataMap => always getting an exeption here "ClassCastException"
                System.out.println(dr.keySet());
            }

Could someone explain me what am I doing wrong in here?
Thanks
Sylwia

Mime
View raw message