The exception stack is nothing more then: Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.Map on the line: Map dr = (Map) o;
I thought that if the SQLTemplate is setted to a Persistent object (PublicationAuthors.class in this case) than the result is going to be a List of this Persistent objects. In this case it returns Object and I can not cast it to anything else. After adding the two column results (X and CNT) as a SQLResult it just doesn't work any more. I don' t know now how can I get the results of the two extra columns X and CNT? Thank you. On 1 September 2011 13:37, Andrus Adamchik <and...@objectstyle.org> wrote: > Could you please post the exception stack trace? > > On Sep 1, 2011, at 1:58 AM, Sylwia Bugla wrote: > >> 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 >> > >