db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thoralf Rickert" <thoralf.rick...@cadooz.de>
Subject AW: weird problem creating sql suery string from criteria
Date Wed, 28 Jun 2006 09:29:33 GMT
Hi!

Did you try to use the doSelectVillageRecords(Criteria) instead of executeQuery(String)? I'm
not sure, but the createQueryString() method is more for debugging then for real queries.

bye
Thoralf


> -----Urspr√ľngliche Nachricht-----
> Von: Steve Vanspall [mailto:svanspall@madman.com.au] 
> Gesendet: Mittwoch, 28. Juni 2006 02:55
> An: torque-user@db.apache.org
> Betreff: weird problem creating sql suery string from criteria
> 
> 
> 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


Mime
View raw message