bczhu1983
bczhu1983
2008-12-19 23:43
浏览 293
已采纳

ibatis 如何出入动态传入指定表和指定列查询对应数据?

ibatis 的配置如下:


<![CDATA[
SELECT $column$ FROM $tableName$
]]>

当传出:tableName: CC_RPT_DF01

column :TO_CHAR(MONTH_CODE,'yyyy-MM-dd hh:mi:ss') MONTH_CODE,decode(BUSINESS_PLACE_CODE,NULL,'',BUSINESS_PLACE_CODE)BUSINESS_PLACE_CODE,decode(PRICE_ID,NULL,'',PRICE_ID)PRICE_ID,decode(TRADE_CODE,NULL,'',TRADE_CODE)TRADE_CODE,decode(INTERVAL,NULL,'',INTERVAL)INTERVAL,decode(TOTAL_POWER,NULL,0,TOTAL_POWER)TOTAL_POWER,decode(TOTAL_POWER_YG,NULL,0,TOTAL_POWER_YG)TOTAL_POWER_YG,decode(TOTAL_POWER_WG,NULL,0,TOTAL_POWER_WG)TOTAL_POWER_WG,decode(FAVOR_POWER,NULL,0,FAVOR_POWER)FAVOR_POWER,decode(ADD_POWER,NULL,0,ADD_POWER)ADD_POWER,decode(TOTAL_FEE,NULL,0,TOTAL_FEE)TOTAL_FEE,decode(CONTENT_FEE,NULL,0,CONTENT_FEE)CONTENT_FEE,decode(CAPA,NULL,0,CAPA)CAPA,decode(CAPA_FEE,NULL,0,CAPA_FEE)CAPA_FEE,decode(NEED,NULL,0,NEED)NEED,decode(NEED_FEE,NULL,0,NEED_FEE)NEED_FEE,decode(BASE_FEE,NULL,0,BASE_FEE)BASE_FEE,decode(COS_ADD_FEE,NULL,0,COS_ADD_FEE)COS_ADD_FEE,decode(COS_REDUCE_FEE,NULL,0,COS_REDUCE_FEE)COS_REDUCE_FEE,decode(FAVOR_FEE,NULL,0,FAVOR_FEE)FAVOR_FEE,decode(ADD_FEE,NULL,0,ADD_FEE)ADD_FEE,decode(SANXIA_FEE,NULL,0,SANXIA_FEE)SANXIA_FEE,decode(CHENGSHI_FEE,NULL,0,CHENGSHI_FEE)CHENGSHI_FEE,decode(PROVINCE_FEE,NULL,0,PROVINCE_FEE)PROVINCE_FEE,decode(STATE_FEE,NULL,0,STATE_FEE)STATE_FEE,decode(NONGWANG_FEE,NULL,0,NONGWANG_FEE)NONGWANG_FEE,decode(ENERGY_FEE,NULL,0,ENERGY_FEE)ENERGY_FEE,decode(OTHER_FEE,NULL,0,OTHER_FEE)OTHER_FEE,decode(USER_COUNT,NULL,0,USER_COUNT)USER_COUNT

能查出CC_RPT_DF01 表对应 列 的数据 。
当第二次传入 tableName:CC_RPT_DF11
column :TO_CHAR(MONTH_CODE,'yyyy-MM-dd hh:mi:ss') MONTH_CODE,decode(BUSINESS_PLACE_CODE,NULL,'',BUSINESS_PLACE_CODE)BUSINESS_PLACE_CODE,decode(VOLTAGE_LEVEL,NULL,'',VOLTAGE_LEVEL)VOLTAGE_LEVEL,decode(SALE_ID,NULL,'',SALE_ID)SALE_ID,decode(USER_NUM,NULL,0,USER_NUM)USER_NUM,decode(SUM_CAPA,NULL,0,SUM_CAPA)SUM_CAPA

Check the selectDataOfTable-AutoResultMap.

--- Check the result mapping for the 'PRICE_ID' property.

--- Cause: java.sql.SQLException: 列名无效; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:

--- The error occurred in com/szp/eai/dataobject/Common.xml.

--- The error occurred while applying a result map.

第二次传入的列名和数据库表中一致。
我感觉好像 SELECT $column$ FROM $tableName$ 这中语句,ibatis记住了第一次出入的列,第二次传入的新列没有用。
要实现这中功能,ibatis该如何做?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • lggegegmail
    lggegegmail 2008-12-21 17:21
    已采纳

    [code="xml"] [/code]

    试试

    点赞 评论

相关推荐