org.springframework.jdbc.UncategorizedSQLException: (SqlMapClient operation): encountered SQLException [  
--- The error occurred in com/ewallpartner/partner/apps/dao/sqlmap/WaibaoNews.xml.  
--- The error occurred while applying a result map.  
--- Check the getNewsList-AutoResultMap.  
--- Check the result mapping for the 'newsType' property.  
--- Cause: java.sql.SQLException: 无法转换为内部表示]; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/ewallpartner/partner/apps/dao/sqlmap/WaibaoNews.xml.  
--- The error occurred while applying a result map.  
--- Check the getNewsList-AutoResultMap.  
--- Check the result mapping for the 'newsType' property.  
--- Cause: java.sql.SQLException: 无法转换为内部表示

解决方案 »

  1.   

    请LZ检查WaibaoNews.xml中的getNewsList返回的ResultMap中newsType属性是否有问题
      

  2.   

    返回的结果集类型用  resultClass="java.util.HashMap"
      

  3.   

    <select id="getNewsList" parameterClass="map" resultClass="com.ewallpartner.partner.apps.domain.waibao.WaibaoNews">
    SELECT 
    B.NEWSID,
    B.SUBJECT,
    B.CONTENTS,
    B.NEWSIMAGE,
    B.BROWSECNT,
    B.REFCNT,
    B.ARRANGEYN,
    B.TOPYN,
    B.USEYN,
    decode(B.NEWSTYPE,'1','行业新闻','2','企业动态','3','外包政策','') as NEWSTYPE
     FROM (
    SELECT
    A.NEWSID,
        A.SUBJECT,
        A.CONTENTS,
    A.NEWSIMAGE,
    A.BROWSECNT,
    A.REFCNT,
    A.ARRANGEYN,
    A.TOPYN,
    A.USEYN,
    A.NEWSTYPE,
    ROWNUM RN FROM (
    select
    t1.NEWS_ID as NEWSID,
            t1.SUBJECT as SUBJECT,
            t1.CONTENTS as CONTENTS,
    t1.NEWS_IMAGE as NEWSIMAGE,
    t1.BROWSE_CNT as BROWSECNT,
    t1.REF_CNT as REFCNT,
    t1.ARRANGE_YN as ARRANGEYN,
    t1.TOP_YN as TOPYN,
    t1.USE_YN as USEYN,
    t1.NEWS_TYPE as NEWSTYPE
    from WAIBAO_NEWS t1
    where 1=1
    <isEqual property="isRange" compareValue="0">
           <isNotNull property="webId">
      and t1.WEB_ID = #webId#
    </isNotNull>
    </isEqual>
           <isNotNull property="topYn">
      and t1.TOP_YN = #topYn#
    </isNotNull>
           <isNotNull property="arrangeYn">
      and t1.ARRANGE_YN = #arrangeYn#
    </isNotNull>
           <isNotNull property="useYn">
      and t1.USE_YN = #useYn#
    </isNotNull>
           <isNotNull property="subject">
      and t1.SUBJECT like '$subject$%'
    </isNotNull>
           <isNotNull property="newsType">
      and t1.NEWS_TYPE = #newsType#
    </isNotNull>
           <isNotNull property="beginDate">
           <isNotNull property="endDate">
       and t1.INSERT_DATE BETWEEN #beginDate# AND #endDate#
       </isNotNull>
    </isNotNull>
    <isNotNull property="orderValue">
    $orderValue$
    </isNotNull>
         <![CDATA[
    ) A WHERE ROWNUM < $endRow$
    ) B WHERE RN >= $startRow$
         ]]>
      </select>
      

  4.   

    你加个log4j.properties 内容如下(谨用,先备份源程序,我出现的一个问题可能是缓存问题导致去除log4j.properties执行sql语句时间依然能够打印出sql):log4j.rootLogger=debug,stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.conversionPattern=[%5p] %d{mm:ss}\
    (%F:%M:%L)%n%m%n%nlog4j.logger.com.ibatis=debug
    log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
    log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
    log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
    log4j.logger.java.sql.Connection=debug
    log4j.logger.java.sql.Statement=debug
    log4j.logger.java.sql.PreparedStatement=debug,stdout
      

  5.   

    是否能够显示出执行的sql,然后再确定
    Cause: java.sql.SQLException: 无法转换为内部表示]; nested exception is com.ibatis.common.jdbc.exception 该错误, 我暂时估计是sql语句有问题。
      

  6.   

    我把 sql 语句复制到 pl/sql 里面能查询出来信息。
      

  7.   

    我没加 log4j 我把控制台 它生成的 sql 语句复制到 pl/sql 里面执行了一下。可以执行。
      

  8.   

    PreparedStatement - {pstm-100004} PreparedStatement:   SELECT    B.NEWSID,   B.SUBJECT,   B.CONTENTS,   B.NEWSIMAGE,   B.BROWSECNT,   B.REFCNT,   B.ARRANGEYN,   B.TOPYN,   B.USEYN,   decode(B.NEWSTYPE,'1','琛屼笟鏂伴椈','2','浼佷笟鍔ㄦ??','3','澶栧寘鏀跨瓥','') as NEWSTYPE   FROM (   SELECT    A.NEWSID,       A.SUBJECT,       A.CONTENTS,    A.NEWSIMAGE,    A.BROWSECNT,    A.REFCNT,    A.ARRANGEYN,    A.TOPYN,    A.USEYN,    A.NEWSTYPE,   ROWNUM RN FROM (    select     t1.NEWS_ID as NEWSID,           t1.SUBJECT as SUBJECT,           t1.CONTENTS as CONTENTS,     t1.NEWS_IMAGE as NEWSIMAGE,     t1.BROWSE_CNT as BROWSECNT,     t1.REF_CNT as REFCNT,     t1.ARRANGE_YN as ARRANGEYN,     t1.TOP_YN as TOPYN,     t1.USE_YN as USEYN,     t1.NEWS_TYPE as NEWSTYPE    from WAIBAO_NEWS t1    where 1=1                     and t1.WEB_ID = ?                        and t1.TOP_YN = ?                   and t1.ARRANGE_YN = ?                   and t1.USE_YN = ?                            and t1.NEWS_TYPE = ?                            ) A WHERE ROWNUM < 10   ) B WHERE RN >= 0          
    PreparedStatement - {pstm-100004} Parameters: [1001, 1, 1, 1, 1]
    PreparedStatement - {pstm-100004} Types: [java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer]
      

  9.   

    你能看出 decode( 这个方法查询出来的值么? 还有一个方法是吧他创建到视图里面。然后再根据条件到视图里面查询。 我也出现过这样的错误,就是字段不能够使用子查询。
      

  10.   

    看不出来 我没用过ibatis 这是其他人写好的。我调用的。没有其他办法了?
      

  11.   

    在数据库表里创建视图,内容为你这条sql where之前的所有。 然后 ibatis只要selet 视图所有字段 from 视图 where 条件!
      

  12.   

    就是把 where 前面所有的字段创建成一张视图 去查询视图?