db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Monroe <mon...@dukece.com>
Subject RE: how can i write torque Group By Query
Date Mon, 01 Dec 2008 15:29:50 GMT
Sorry for the delay... Last week was the Thanksgiving 
holiday in the US...

The easy way to do this (once it's set up), would be to use the new
SummaryHelper class.  However, this was not finished in time to make
the current distribution and is only available in the SVN repository.

Here is a link to the email talking about this:

http://mail-archives.apache.org/mod_mbox/db-torque-dev/200803.mbox/%3C8F5843B903F59D4C8C6806BB49A3911906016692@dukece-mail3.dukece.com%3E

You can also look at the Javadoc comments of this class to see if you 
want to build/use a snapshot Runtime.  AFAIK, there have been no other 
major submits to the 3.x build tree (since 4.0 is separate).  So, I'd
say that it would be production ready (I'm using it that way now).

An alternative way to do this is via Torque is to use the BasePeer
executeQuery methods.  This is a lower level way to use Torque to 
execute queries that don't fit into the record object model.  It 
returns a set of Record objects that are a lot like the standard JDBC
classes with getValue methods for getting data by ordinal or columnName.

Finally, if this particular query is something you do a lot and still 
want the convenience of a Torque record, you could create an SQL view
and then create a pseudo-table in the schema (use the noSql option) to
match the columns the view will create.  It may not fit your need but I
thought I'd mention it.


> -----Original Message-----
> From: Sasikumar Natarajan [mailto:nsasi_cts@yahoo.com]
> Sent: Monday, December 01, 2008 12:30 AM
> To: Apache Torque Users List
> Subject: Re: how can i write torque Group By Query
> 
> Hello ALL,
>            i have been developed a oracle query for getting employees
> count in each department as given below. This query i want to change
> Torque Query as Similar functionality by using Peer Class Joint. Can u
> Please help me for converting by using Peer Class Joint.
> 
> SELECT DEPT_NUMBER, DEPT_NAME, COUNT(DEPT_NUMBER) NUMBER_OF_EMPLOYEES
> FROM EMPLOYEES EMP, DEPARTMENTS DEPT
> WHERE EMP.EMP_DEPT_NUMBER = DEPT.DEPT_NUMBER GROUP BY DEPT_NUMBER,
> DEPT_NAME
> 
> Thanks In Advance
> Sasikumar
> 
> --- On Wed, 26/11/08, Sasikumar Natarajan <nsasi_cts@yahoo.com> wrote:
> 
> From: Sasikumar Natarajan <nsasi_cts@yahoo.com>
> Subject: how can i write torque Group By Query
> To: "Apache Torque Users List" <torque-user@db.apache.org>
> Date: Wednesday, 26 November, 2008, 12:39 PM
> 
> Hi All
> 
> The following query i need to change by using torque query.
> 
> SELECT DEPT_NUMBER, DEPT_NAME, COUNT(DEPT_NUMBER) NUMBER_OF_EMPLOYEES
> FROM
> EMPLOYEES EMP, DEPARTMENTS DEPT
> WHERE EMP.EMP_DEPT_NUMBER = DEPT.DEPT_NUMBER GROUP BY DEPT_NUMBER,
> DEPT_NAME
> 
> i did the following by using torque query. but this is wrong.
> 
> Please help me to correct the following query.
> 
> Criteria criteria = new Criteria();
> criteria.addSelectColumn(DepartmentPeer.DEPT_NUMBER);
> criteria.addSelectColumn(DepartmentPeer.DEPT_NAME);
> 
> criteria.addGroupByColumn(DepartmentPeer.DEPT_NUMBER);
> criteria.addGroupByColumn(DepartmentPeer.DEPT_NAME);
> 
> criteria.addJoin(EmployeePeer.EMP_DEPT_NUMBER,
> DepartmentPeer.DEPT_NUMBER);
> List deptList = DepartmentPeer.doSelect(criteria);
> 
> Thanks in Advance
> Sasikumar
> 
> 
>       Unlimited freedom, unlimited storage. Get it now, on
> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
> 
> 
>       Add more friends to your messenger and enjoy! Go to
> http://messenger.yahoo.com/invite/

DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.
Mime
View raw message