You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marek Šabo <ms...@buk.cvut.cz> on 2010/02/07 12:39:39 UTC

SQLResultMapping missing in RC2?

Hi all,

I was using this chunk of code to return number of records in table:

	SQLTemplate sq = new SQLTemplate(User.class, "SELECT COUNT(id) C from User;");
        SQLResultSetMapping rsMap = new SQLResultSetMapping();
        rsMap.addColumnResult("C");
        sq.setResultSetMapping(rsMap);
        Long users = (Long) DataObjectUtils.objectForQuery(getObjectContext(), sq);


This code worked the whole way with cayenne 3 but after upgrade to rc2
(maven repo) the SQLResultSetMapping class is missing. Did you change
some workflow and added alternative to this? If so then please could you
provide it?
Anyway, I find this piece of code rather colossal for simple procedure
as count (I figure this is a common usecase) so is there an easier way
to work with aggreagate functions?

TIA,

--
Marek Šabo


Re: SQLResultMapping missing in RC2?

Posted by Andrus Adamchik <an...@objectstyle.org>.
SQLResultSetMapping got renamed in the course of 3.0 development to  
just SQLResult (from the commit logs, sometime in the fall of 2008).  
So you can just rename it in your code.

Let me also check the docs. There may be some mentions of  
SQLResultSetMapping that need to be updated.

Andrus

On Feb 7, 2010, at 1:39 PM, Marek Šabo wrote:

> Hi all,
>
> I was using this chunk of code to return number of records in table:
>
> 	SQLTemplate sq = new SQLTemplate(User.class, "SELECT COUNT(id) C  
> from User;");
>        SQLResultSetMapping rsMap = new SQLResultSetMapping();
>        rsMap.addColumnResult("C");
>        sq.setResultSetMapping(rsMap);
>        Long users = (Long)  
> DataObjectUtils.objectForQuery(getObjectContext(), sq);
>
>
> This code worked the whole way with cayenne 3 but after upgrade to rc2
> (maven repo) the SQLResultSetMapping class is missing. Did you change
> some workflow and added alternative to this? If so then please could  
> you
> provide it?
> Anyway, I find this piece of code rather colossal for simple procedure
> as count (I figure this is a common usecase) so is there an easier way
> to work with aggreagate functions?
>
> TIA,
>
> --
> Marek Šabo
>
>