db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tulsi Das <quixote_...@yahoo.com>
Subject order by an alias problem...
Date Tue, 07 Oct 2003 21:16:44 GMT
Hello, using Torque with MySQL I want to do an "order by" using some
alias column and not a table column. That is, something like this:

SELECT actividad.*, MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') AS
score FROM actividad 
WHERE MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') order by score
desc


that is, using full text seach, sort by the score of that result.

To achieve that, I use the following code:

String matchString = "MATCH ("+ActividadPeer.ACTIVIDAD+") AGAINST
(\'"+texto+"\')";

Criteria crit = new Criteria();		
crit.add(ActividadPeer.ACTIVIDAD, (Object)matchString,
Criteria.CUSTOM);
		
crit.addAsColumn("score", matchString);
crit.addDescendingOrderByColumn("score");

List actividades = ActividadPeer.doSelect(crit);

If I comment the addDescendingOrderByColumn line, everything goes well
and the full text goes ok, but when trying to do the order by, I get
the following error:

org.apache.torque.TorqueException: Malformed column name in Criteria
order by: 'score DESC' is not of the form 'table.column'


Now... I know it what it means, but I don´t want a table.column form,
since it´s an alias!

Any input on the subject will be much appreciated

thanks

Tulsi



------------
Internet GRATIS es Yahoo! Conexión
4004-1010 desde Buenos Aires. Usuario: yahoo; contraseña: yahoo
Más ciudades: http://conexion.yahoo.com.ar

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


Mime
View raw message