You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jürgen Hoffmann <jh...@byteaction.de> on 2003/03/31 09:39:49 UTC

AW: Torque Problem

Hi Donald,
 
I am using eclipse 2.1 as my ide and use jpda to step trace any bugs in
my webapps with torque/turbine. First thing. If I am creating a complex
query that uses joins or distincts, criteria is very error prone. 
In these cases I am using Torques Ability to use "self-written" sql.
This is done by using the following syntax.
 
BasePeer.executeQuery(<sql>);
http://db.apache.org/torque/apidocs/org/apache/torque/util/BasePeer.html
#executeQuery(java.lang.String)
 
This returns you a List with com.workingdogs.village.Record Objects,
which you can then map to your objects using:
 
YourGeneratedPeerClass.populateObjects(ListOfVillageRecords)
 
Please remember that this mapping only works if you have all necessary
columns in your SELECT Statement and they are in the correct order.
 
Otherwise you can iterate over the Record Objects using:
 
 
for (Iterator iter = RecordList.iterator(); iter.hasNext();)
{
    Record element = (Record)iter.next();
    int column = 1;
    String firstName = element.getValue(column).asString(); // only as
an example
    int column = 2;
    String lastName = element.getValue(column).asString(); // only as an
example
    .
    .
    .
}
 
HTH 
 
 

Kind regards


Jürgen Hoffmann
ByteACTION GmbH

cert. Perl Programmer
cert. Linux System Administrator
cert. Java Programmer



-----Ursprüngliche Nachricht-----
Von: Donald Rosengartner [mailto:DROSENGARTNER@kc.rr.com] 
Gesendet: Sonntag, 30. März 2003 06:55
An: jh@byteaction.de
Betreff: Torque Problem


First, your English is very good. Did you study in America previously? I
lived in Tuebingen, Germany in 1992-3 while My ex-wife studied there. I
wish my German was half what your english appears to be. Anyway, please
consider the following question. I've seen many postings on the torque
newslist for this problem, but nothing that resembles a solution. After
seeing your posting dated 2-15-03, I believe you might have enough
expertise to handle this.. if you're willing.
 
Database is MySql. Torque vs. torque-3.0-rc2
My tables are CUSTOMER, LOCATION, CATEGORY.
My criteria object is being built like this:
 
locationCrit.add(LocationPeer.FK_STATE, stateCode);
locationCrit.add(CategoryMinorPeer.CATEGORY_NAME,(Object)(CategoryMinorP
eer.CATEGORY_NAME + " LIKE '" + minorCategory + "'"),Criteria.CUSTOM);
locationCrit.addJoin(CategoryMinorPeer.FKCUSTOMER_ID,CustomerPeer.CUSTOM
ER_ID);
locationCrit.addJoin(LocationPeer.FKCUSTOMER_ID,CustomerPeer.CUSTOMER_ID
);
 
locationCrit.addOrderByColumn(CustomerPeer.CUSTOMER_NAME);
locationCrit.addGroupByColumn(CustomerPeer.PAID_AD);
locationCrit.setDistinct();
List marinas = (List) CustomerPeer.doSelect(companyCrit);
 
***************
Problem(1): if OrderBy,GroupBy are used together the whole thing fails;
The database is never hit, and the sql does not get written to the
Tomcat console. As a workaround, I'm considering a
Collections.sort(listname) with no luck so far. Have you attempted
anything like this? I believe the Customer object is mapped somehow to
the two joined tables allowing the customer.getCategory() method. Is
this perhaps interferring with the sort of Customer?
 
(2) On the distinct portion, the sql is being created as if intended:
select distinct(col1,col2,col3,col4,col5,...) from ...
instead of:
select distinct(col1) col2, col3, col4 ... from ...
 
(3) What are the import statements on your extended BasePeer that
enables logging for your debugging? Or is this capability enabled
through some properties setting in your torque setup?
 
Do you have an IDE for step tracing your code? My brother is a linux
administrator and recommended Eclipse from IBM. I'm using Win2K and had
problems running both Sun1 and  JBuilder. I installed Eclipse, but still
getting familiar with it. Only thing I can say is that it's super fast
compared to Sun/JB. Thanks in advance for considering my issues with
torque.
 
God Bless,
Don Rosengartner


Re: Torque Problem

Posted by Akmal Sarhan <as...@byteaction.de>.
pay attention that CATEGORY has some issues with torque/turbine and you
should change the name if you want to use torque :(
regards
Akmal
----- Original Message -----
From: "Jürgen Hoffmann" <jh...@byteaction.de>
To: "'Donald Rosengartner'" <DR...@kc.rr.com>
Cc: <to...@db.apache.org>; <tu...@jakarta.apache.org>
Sent: Monday, March 31, 2003 9:39 AM
Subject: AW: Torque Problem


Hi Donald,

I am using eclipse 2.1 as my ide and use jpda to step trace any bugs in
my webapps with torque/turbine. First thing. If I am creating a complex
query that uses joins or distincts, criteria is very error prone.
In these cases I am using Torques Ability to use "self-written" sql.
This is done by using the following syntax.

BasePeer.executeQuery(<sql>);
http://db.apache.org/torque/apidocs/org/apache/torque/util/BasePeer.html
#executeQuery(java.lang.String)

This returns you a List with com.workingdogs.village.Record Objects,
which you can then map to your objects using:

YourGeneratedPeerClass.populateObjects(ListOfVillageRecords)

Please remember that this mapping only works if you have all necessary
columns in your SELECT Statement and they are in the correct order.

Otherwise you can iterate over the Record Objects using:


for (Iterator iter = RecordList.iterator(); iter.hasNext();)
{
    Record element = (Record)iter.next();
    int column = 1;
    String firstName = element.getValue(column).asString(); // only as
an example
    int column = 2;
    String lastName = element.getValue(column).asString(); // only as an
example
    .
    .
    .
}

HTH



Kind regards


Jürgen Hoffmann
ByteACTION GmbH

cert. Perl Programmer
cert. Linux System Administrator
cert. Java Programmer



-----Ursprüngliche Nachricht-----
Von: Donald Rosengartner [mailto:DROSENGARTNER@kc.rr.com]
Gesendet: Sonntag, 30. März 2003 06:55
An: jh@byteaction.de
Betreff: Torque Problem


First, your English is very good. Did you study in America previously? I
lived in Tuebingen, Germany in 1992-3 while My ex-wife studied there. I
wish my German was half what your english appears to be. Anyway, please
consider the following question. I've seen many postings on the torque
newslist for this problem, but nothing that resembles a solution. After
seeing your posting dated 2-15-03, I believe you might have enough
expertise to handle this.. if you're willing.

Database is MySql. Torque vs. torque-3.0-rc2
My tables are CUSTOMER, LOCATION, CATEGORY.
My criteria object is being built like this:

locationCrit.add(LocationPeer.FK_STATE, stateCode);
locationCrit.add(CategoryMinorPeer.CATEGORY_NAME,(Object)(CategoryMinorP
eer.CATEGORY_NAME + " LIKE '" + minorCategory + "'"),Criteria.CUSTOM);
locationCrit.addJoin(CategoryMinorPeer.FKCUSTOMER_ID,CustomerPeer.CUSTOM
ER_ID);
locationCrit.addJoin(LocationPeer.FKCUSTOMER_ID,CustomerPeer.CUSTOMER_ID
);

locationCrit.addOrderByColumn(CustomerPeer.CUSTOMER_NAME);
locationCrit.addGroupByColumn(CustomerPeer.PAID_AD);
locationCrit.setDistinct();
List marinas = (List) CustomerPeer.doSelect(companyCrit);

***************
Problem(1): if OrderBy,GroupBy are used together the whole thing fails;
The database is never hit, and the sql does not get written to the
Tomcat console. As a workaround, I'm considering a
Collections.sort(listname) with no luck so far. Have you attempted
anything like this? I believe the Customer object is mapped somehow to
the two joined tables allowing the customer.getCategory() method. Is
this perhaps interferring with the sort of Customer?

(2) On the distinct portion, the sql is being created as if intended:
select distinct(col1,col2,col3,col4,col5,...) from ...
instead of:
select distinct(col1) col2, col3, col4 ... from ...

(3) What are the import statements on your extended BasePeer that
enables logging for your debugging? Or is this capability enabled
through some properties setting in your torque setup?

Do you have an IDE for step tracing your code? My brother is a linux
administrator and recommended Eclipse from IBM. I'm using Win2K and had
problems running both Sun1 and  JBuilder. I installed Eclipse, but still
getting familiar with it. Only thing I can say is that it's super fast
compared to Sun/JB. Thanks in advance for considering my issues with
torque.

God Bless,
Don Rosengartner




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org