Use SELECT MAX(?index?)
FROM (?nom?)
If you want to do a replacement
Also switch logging on so you can see the created query
MEINDERT HOVING
-----Original Message-----
From: Stéphane Chapeau [mailto:s.chapeau@c3consultants.fr]
Sent: 04 April 2006 09:21 AM
To: user-java@ibatis.apache.org
Subject: Select max(#A#) from (#B#) error
Hello,
I try to pass argument by a class, by xml map and by this method. And it's
always the same problem :
public class MetSqlMapDao extends BaseSqlMapDao implements MetDao {
[...]
public void getMax() {
Hashtable ht = new Hashtable();
ht.put("index","idMeti");
ht.put("nom","metiers");
log.debug((Integer)queryForObject("getMaxId", ht));
}
Tool.xml :
[...]
<statement id="getMaxId" resultClass="java.lang.Integer"
parameterClass="java.util.Map">
SELECT MAX(#index#)
FROM (#nom#)
</statement>
And I have the folowing error, it seems like ibatis don't set the right
arguments :
com.ibatis.dao.client.DaoException: Failed to execute queryForObject - id
[getMaxId], parameterObject [{nom=metiers, index=idMeti}]. Cause:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in org/c3/emc3/persistence/sqlmapdao/sql/Tool.xml.
--- The error occurred while applying a parameter map.
--- Check the getMaxId-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ERREUR: syntax error near «$2»
If I put directly the parameters in the XML file for the SQL request, the
result is ok. I don't see where is the problem ?
Thanks
--
Stephane Chapeau,
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.5/300 - Release Date: 03/04/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.5/300 - Release Date: 03/04/2006
|