日期:2014-05-19  浏览次数:20780 次

iBatis怎样比较时间大小?数据库里格式为String
本帖最后由 xzs7190966 于 2012-12-12 17:18:40 编辑


<select id="queryPerByName"  parameterClass="Personnel" resultClass="Personnel" >
      select * from cms_personnel 
      <dynamic prepend="where">
          <isNotEmpty prepend="and" property="name" >
             name=#name#
          </isNotEmpty>
          <isNotEmpty prepend="and" property="s_time" >
           <![CDATA[   s_time >  '#s_time#' ]]>
          </isNotEmpty> 
          <isNotEmpty prepend="and" property="e_time" >
           <![CDATA[  e_time  <  '#e_time#' ]]>  
          </isNotEmpty>       
      </dynamic>
   </select>



----------------------------------------
部分报错代码


DEBUG http-8080-5 - {conn-100054} Preparing Statement:        select * from cms_personnel        where                                     s_time >  "?"                                          
 DEBUG http-8080-5 - Fetching JDBC Connection from DataSource
 DEBUG http-8080-5 - Returning JDBC Connection to DataSource
 com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred while applying a parameter map.  
--- Check the sum_queryPerByName-InlineParameterMap.  
--- Check the parameter mapping for the 's_time' property.  
--- Cause: java.sql.SQLException: No parameters defined during prepareCall()
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
at com.ibatis.sqlmap.engine.impl.SqlMapSes