You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Rusty Geldmacher <ru...@wpi.edu> on 2002/05/06 06:56:54 UTC
Torque newbie question
Hello,
I'm just getting started using Torque, and I think I hit a road
block. I can't seem to figure out how to do SQL "GROUP BY" statements
using the Criteria object. Could someone please help me out by showing
me an example of how to do this? I figured there would be an
"addGroupBy" method for the Criteria object but I guess it's trickier
than that. If it turns out there's not a way to do this, how have you
gotten around that limitation? Also, if there's no way to do this,
could someone point out to me where I might start implementing this
functionality? Any help is appreciated. Thank you!
rusty geldmacher
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Torque newbie question
Posted by Sam Joseph <ga...@yha.att.ne.jp>.
Rusty Geldmacher wrote:
> I'm just getting started using Torque, and I think I hit a road
>block. I can't seem to figure out how to do SQL "GROUP BY" statements
>using the Criteria object. Could someone please help me out by showing
>me an example of how to do this? I figured there would be an
>"addGroupBy" method for the Criteria object but I guess it's trickier
>than that.
>
I submitted a patch a few days ago that adds GROUP BY and HAVING
functionality to the Criteria class. It's not a big change, but it's not
up to me when it gets added.
There are a number of potential changes to the Criteria class at the
moment, so it might be a little while.
CHEERS> SAM
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Torque newbie question
Posted by Maciej Leks <ml...@zeus.polsl.gliwice.pl>.
Hello Rusty,
Torque API structure looks like this
1. JDBC
2. Village
3. Torque API
Torque is based on the Village which extends JDBC functionality...
So when you looks for more advance SQL functionality and Torque do not
support its, you can go down and use Village or JDBC API...Usually
Village will be enough!
So, you want use group by statement...
import com.workingdogs.village.*;
import org.apache.turbine.om.peer.BasePeer;
...
String qyery="SELECT person_id, first_name, last_name FROM person
GROUP BY sex";
Vector v = BasePeer.executeQuery(query);
for (int i = 0; i < v.size(); i++)
{
Record record = ((Record)v.elementAt(i));
Log.info("personId=" + record.getValue(1).asInt() + " firstName="
+record.getValue(2).asString() + " lastName" +
record.getValue(3).asString() );
}
Of course you can put the query result(Vector) into the context and use it in
your Village template...
Village is a better solution for queries that return a lots of records,
because of memory management. Torque wrap each returned record into
a business object what is not healthy for the memory!
Best Regards
RG> I'm just getting started using Torque, and I think I hit a road
RG> block. I can't seem to figure out how to do SQL "GROUP BY" statements
RG> using the Criteria object. Could someone please help me out by showing
RG> me an example of how to do this? I figured there would be an
RG> "addGroupBy" method for the Criteria object but I guess it's trickier
RG> than that. If it turns out there's not a way to do this, how have you
RG> gotten around that limitation? Also, if there's no way to do this,
RG> could someone point out to me where I might start implementing this
RG> functionality? Any help is appreciated. Thank you!
______________________________________
Leksiu (mleks@zeus.polsl.gliwice.pl)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Torque newbie question
Posted by Eric Dobbs <er...@dobbse.net>.
On Sunday, May 5, 2002, at 10:56 PM, Rusty Geldmacher wrote:
> I can't seem to figure out how to do SQL "GROUP BY" statements
> using the Criteria object.
Have a look Torque 3.0 b2 (released today). It
includes Sam's patches for GROUP BY and HAVING.
Also, please send future torque questions here:
turbine-torque-user@jakarta.apache.org
-Eric
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>