后台列名无效

Posted on 2010-10-09 13:59  LuckCOffey  阅读(4188)  评论(0)    收藏  举报

如果后台报列名无效  

 

--- The error occurred incom/bluechips/ibatis/entity/xml/fund.xml. 

--- The error occurred whileapplying a result map. 

--- Check theFund.fundResult. 

--- Check the result mapping forthe 'fund_type' property. 

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

--- The error occurred incom/bluechips/ibatis/entity/xml/fund.xml. 

--- The error occurred whileapplying a result map. 

--- Check theFund.fundResult. 

--- Check the result mapping forthe 'fund_type' property. 

--- Cause: java.sql.SQLException: 列名无效

Caused by: java.sql.SQLException: 列名无效

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:  

--- The error occurred incom/bluechips/ibatis/entity/xml/fund.xml. 

--- The error occurred whileapplying a result map. 

--- Check theFund.fundResult. 

--- Check the result mapping forthe 'fund_type' property. 

--- Cause: java.sql.SQLException: 列名无效

Caused by: java.sql.SQLException: 列名无效

 

 

 

 

可能出现的问题的地方

1   是不是你的sql语句写错啦跟数据库的对不上

2   可能是你的Ibatis里面的xml文件没有写对

 <?xml version="1.0" encoding="UTF-8"standalone="no"?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN""http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="Fund">

    <typeAlias alias="fund" type="com.bluechips.entity.Fund"/>

 

    <resultMap id="fundResult" class="fund">

       <result property="fund_id" column="fund_id"/>

       <result property="fund_name" column="fund_name"/>

       <result property="code" column="code"/>

       <result property="fund_type" column="fund_type"/>

       <result property="administrater" column="administrater"/>

 

    </resultMap> 

  //就是这里的sql语句中的字段是不是跟上面的<resultMap>中的column="fund_id"一致

    <select id="getFundList2" resultMap="fundResult">

        select fund_name, code,fund_id  from FUND  where fund_type=1 or fund_type=2

 

    </select>

</sqlMap>

 

3 可能是你的xml中sql语句没有 写完<resultMap>中的所有字段

 

<?xml version="1.0" encoding="UTF-8"standalone="no"?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN""http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="Fund">

    <typeAlias alias="fund" type="com.bluechips.entity.Fund"/>

 

    <resultMap id="fundResult" class="fund">

       <result property="fund_id" column="fund_id"/>

       <result property="fund_name" column="fund_name"/>

       <result property="code" column="code"/>

       <result property="fund_type" column="fund_type"/>

       <result property="administrater" column="administrater"/>

 

    </resultMap> 

  //就是这里的sql语句中的字段是不是跟上面的<resultMap>中的字段一样多

    <select id="getFundList2" resultMap="fundResult">

        select fund_name, code,fund_id  from FUND  where fund_type=1 or fund_type=2

 

    </select>

</sqlMap>

也可以写成

 

<?xml version="1.0" encoding="UTF-8"standalone="no"?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN""http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="Fund">

    <typeAlias alias="fund" type="com.bluechips.entity.Fund"/>

 

    <resultMap id="fundResult" class="fund">

       <result property="fund_id" column="fund_id"/>

       <result property="fund_name" column="fund_name"/>

       <result property="code" column="code"/>

       <result property="fund_type" column="fund_type"/>

       <result property="administrater" column="administrater"/>  

    </resultMap>

 

    <resultMap id="fundResult2" class="fund">

       <result property="fund_id" column="fund_id"/>

       <result property="fund_name" column="fund_name"/>

       <result property="code" column="code"/>      

    </resultMap>

 

 

    <select id="getFundList" resultMap="fundResult">

       SELECT * FROM fund

    </select>

 

    <select id="getFundList2" resultMap="fundResult2">

select fund_name, code ,fund_id FROM fund  where fund_type=1 orfund_type=2

    </select>

</sqlMap>

 

 

 

 

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3