ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Broderick, Kevin" <kevin.broder...@iona.com>
Subject RE: Select max(#A#) from (#B#) error
Date Tue, 04 Apr 2006 07:38:02 GMT
Hi Stéphane,
Perhaps there is a problem with passing a Hashtable to a sql statement that is expecting a
map.
If you use HashMap in your class and java.util.HashMap as your parameterClass this should
work.
Cheers,
Kevin

-----Original Message-----
From: Stéphane Chapeau [mailto:s.chapeau@c3consultants.fr] 
Sent: 04 April 2006 08:21
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,



Mime
View raw message