db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Holtzman <j...@joshholtzman.com>
Subject Re: Simple select in Torque gets difficult???
Date Wed, 12 Nov 2003 14:26:28 GMT
>In my opinion Criteria and Criterion are like an "SQL Builder" for people
>who doesn't know/like the SQL language.
>But I don't see yet the real advantages.


I can see your point, but there is one very important feature that you 
overlook:

SQL isn't consistent across database systems.  An MS SQL query, for 
instance, can look significantly different than a MySQL query intended 
to do the same thing.  If I chose to use straight SQL over using 
Criteria, I would hate to have to go through all of my code and modify 
every query just to move database systems (which I happen to do a lot).

Although I've found Criteria to be a little weak when constructing 
complex queries, I've also found them to be simple and effective ~80% of 
the time (I write  torque/struts webapps).  For the rest of the time, 
there's executeQuery.  So the way I see it, Criteria is a great tool for 
keeping SQL out of my code where it doesn't belong... most of the time.

Josh


I also prefer

Amine Bousta wrote:

>I do agree with you. I'm not satisfied with Criteria and Criterion objects
>as well.
>I think SQL is more easy to read and fix and I always use "executeQuery"
>instead of "doSelect".
>That's more simple for parenthisis issues for exemple.
>
>But I think Torque is a very good tool. If you want to encourage your
>collegues to use Torque I think you shouldn't say that it's used to avoid
>writing SQL. But it is usefull to generate automatically beans and bean
>Peers from a schema.
>Since I use Torque I've gained a lot of time by avoiding writing beans.
>I'm very satisfied by Torque because beans manage very well foreign keys.
>When you generate Base beans then you just have to focus on specific methods
>and you don't manage database connections.
>These are for me the most interesting points.
>
>Doing a doSelect with Criteria and Criterion is a nightmare for me as well,
>but doing updates with set and save is really easy, and results (coming from
>an executeQuery or from a doSelect it's the same) are easy to explore as
>well.
>
>So Torque is a great database management tool but I'm always wondering what
>is the real use of Criteria and Criterion whereas you can do sql queries
>that are easiest to read, write and fix. I see a lot of people using
>Criteria.CUSTOM beacause they can't do their queries with normal Criterias.
>But using Criteria.CUSTOM is mostly like writing directly in sql...
>
>In my opinion Criteria and Criterion are like an "SQL Builder" for people
>who doesn't know/like the SQL language.
>But I don't see yet the real advantages.
>
>If anybody can list me the advantages of Criteria/Criterion vs SQL I'll be
>very interested
>
>Thanks
>Amine
>
>
>-----Message d'origine-----
>De : Javier.Olcina@uv.es [mailto:Javier.Olcina@uv.es]
>Envoyé : mercredi 12 novembre 2003 10:31
>À : torque-user@db.apache.org
>Objet : Simple select in Torque gets difficult???
>
>
>Another simple question.How can I do something like this?
>
>select * from author where (firs_name='Frank' AND last_name='Black') OR
>(firs_name='Michael' AND last_name='White')
>
>Notes:
>- I there is a bug in OR as It was said in other messages
>- Criteria as far as I know does not allow to do that: differents
>comparisons to a column. ??
>- I think that I have to use Criterion to do that select, but then
>something so simple like this in SQL become 10 code lines long. That's
>something difficult to justify to my project collegues in order to
>encourage them to use Torque.
>
>
>---------------------------------------------------------------------
>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