db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Vanspall" <svansp...@madman.com.au>
Subject RE: weird problem creating sql suery string from criteria
Date Sun, 02 Jul 2006 23:16:11 GMT
Oh ok, no never run to string because I don't find it that useful.

Like I said If I developed a test case, you would be hard pressed to get
it to break. As it is it happens only once in a while, with the same
code.

Have, for now, just manually created the SQL statement and the select
the records using Torque. That seems to work every time.

Steve

-----Original Message-----
From: Thomas Fischer [mailto:tfischer@apache.org] 
Sent: Saturday, 1 July 2006 12:46 AM
To: Apache Torque Users List
Subject: RE: weird problem creating sql suery string from criteria

This is the first time I ever heard of something like this. Could you 
provide more details on when this happens ? E.g. can you provide a test 
case or something like that where one can reproduce the behaviour you 
see ?

The only reason I could imagine this happen because of Torque is the 
following: There could be an issue in the toString() method, so that in 
the debug mode of the ide, you run into a breakpoint and the toString() 
method of Criteria gets called, which could change the state of your 
criteria.

     Thomas

On Fri, 30 Jun 2006, Steve Vanspall wrote:

> Oh right no problem
>
> The odd problem is that my code works about 85% of the time with the
> same criteria beign set.
>
> It's more the lack of consistency that concerns me. Why should Torque
> not perform the task correctly only some of the time.
>
> But thanks I will look into the counthelper
>
> Steve
>
> -----Original Message-----
> From: Thomas Fischer [mailto:tfischer@apache.org]
> Sent: Thursday, 29 June 2006 7:19 PM
> To: Apache Torque Users List
> Subject: Re: weird problem creating sql suery string from criteria
>
> The problem is that count(*) as only select column will not work.
Torque
>
> neends some hint on which table the select runs on (unfortunately, the
> peer class does not do that), and it uses the select column name to do
> that.
>
> Have you looked at the CountHelper class in Torque 3.2 ? I'd recommend
> using it, or, if that is not possible, enhance its source code.
>
>     Thomas
>
> On Wed, 28 Jun 2006, Steve Vanspall wrote:
>
>> Hi
>>
>>
>>
>> I have a problem where If I set criteria add a select column, 95% of
> the
>> time getting a SQL query string from the criteria works. But
>> occasionally it doesn't create a calid SQL string.
>>
>>
>>
>> This is the code
>>
>>
>>
>>            // create the count criteria
>>
>>            Criteria rarCriteria = new Criteria();
>>
>>            rarCriteria.addSelectColumn("COUNT(*)");
>>
>>            getReturnAuthorisationRequestSearchCriteria(rarCriteria);
>>
>>            String query = ReturnAuthorisationRequestPeer
>>
>>                        .createQueryString(rarCriteria);
>>
>>            List list = ReturnAuthorisationRequestPeer.executeQuery(
>>
>>
>> ReturnAuthorisationRequestPeer.createQueryString(rarCriteria),
>>
>>                        ReturnAuthorisationRequestPeer.DATABASE_NAME);
>>
>>            return ((Record) list.get(0)).getValue(1).asInt();
>>
>>
>>
>>
>>
>> /*
>>
>> getReturnAuthorisationRequestSearchCriteria(rarCriteria); just adds
> the
>> criteria using the standard Torque methods. add, some criterion
and's,
>> and depending on the conditions a join.
>>
>> */
>>
>>
>>
>> Now when I run this once, with all the same settings it will work.
>> Occasionally it will throw a SQL syntax error in my sql.
>>
>>
>>
>> All the conditions fo creating the criteria will be the same as the
>> previous (succesful) criteria build.
>>
>>
>>
>> When it fails,
>> ReturnAuthorisationRequestPeer.createQueryString(rarCriteria) create
a
>> string "Select COUNT(*) FROM" with nothin else. Obvioulsy when it
> works
>> it produces the complete SQL string.
>>
>>
>>
>> Why does Torque selectively create the SQL differently? Is this a
bug?
>> Is there any way to guarantee that this will work every time.
> Otherwise
>> I will have ot manually build an SQL string.
>>
>>
>>
>> Any help would be appreciated
>>
>>
>>
>> Regards
>>
>>
>>
>> Steve
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>

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




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


Mime
View raw message