|----------------------------------------------------------------------------------------------------------------------------------------------------> |Jay Bourland wrote: | |----------------------------------------------------------------------------------------------------------------------------------------------------> >---------------------------| | An: | >---------------------------|
> I'm trying to convert an old Torque site to version 4. I'm running > into a problem with using a count() function. The code looks like this: > > Criteria crit = getCriteriaDogsWithAllTitles( titles, year ); > > SummaryHelper summary = new SummaryHelper(); > > summary.addAggregate( "count", new Count( DogPeer.DOG_ID ) ); > List<ListOrderedMapCI> results = summary.summarize( crit ); > > When summarize() is executed, I get a > "jdbc4.MySQLSyntaxErrorException: You have an error in your SQL > syntax" exception. The Criteria is good and works fine with a > doSelect(). It appears that the summarize converts the Criteria to a > string without adding in the replacements for the parameters in the > prepared statement. Can you please provide an example how you construct a crit which fails ? > Also, if I take the string from the > queryStatement and replace the '?' with values, the statement runs > fine from an interactive MySQL session. When I compare the code in > SummaryHelper.summarize() to BasePeerImpl.doSelect() the code to set > the replacements is present in doSelect but not in summarize. > > What's the best way to report this? Please file a jira issue at https://issues.apache.org/jira/browse/TORQUE/ As a workaround, you can try crit.addSelectColumn(new org.apache.torque.util.functions.Count ("*")); int count = SomePeer.doSelectSingleRecord(crit, new org.apache.torque.om.mapper.IntegerMapper()); instead of summary.addAggregate( "count", new Count( DogPeer.DOG_ID ) ); List<ListOrderedMapCI> results = summary.summarize( crit ); Thomas --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org